通过AD扩展属性为用户启用Google Workspace权限
时间:
2022-05-31 17:17:40
阅读:
137
评论:
0
收藏:
0
[点我收藏+]
原文:https://blog.51cto.com/magic3/5347493
脚本内容:
param (
# [Parameter(Mandatory=$True)]
[string]$UserName
)
Import-Module ActiveDirectory
#$UserName = $args[0]
$SamAccount = (Get-ADUser -Filter {(Name -eq $UserName) -or (SamAccountName -eq $UserName)}).SamAccountName
$Custom = @{}
$Custom['ExtensionAttribute1‘] = ‘GoogleGsuite‘
Set-ADUser -Identity $SamAccount -Add $Custom
Start-Sleep -s 60
$Gsuite = (Get-ADUser -Identity $SamAccount -Properties *).extensionAttribute1
if($Gsuite -eq 'GoogleGsuite‘)
{
write-output "$UserName,Google GSuite Enable successfully!"
}
else
{
$GoogleGsuiteValue = Get-ADUser -Identity $User -Properties * | %{$_.extensionAttribute1}
$GsuiteValue = "$GoogleGsuiteValue"
$GsuiteValueDictionary = @{"GoogleGSuite"="Judgment Error";""="Google GSuite Not Enabled" }
$GoogleGsuiteValueReport = $GsuiteValueDictionary[$GsuiteValue]
}
如图示:


标签:
(0)