0
点赞
收藏
分享

微信扫一扫

通过AD扩展属性为用户启用Google Workspace权限

蛇发女妖 2022-05-31 阅读 77


脚本内容:

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]

}


如图示:

通过AD扩展属性为用户启用Google Workspace权限_powershell


通过AD扩展属性为用户启用Google Workspace权限_powershell_02

举报

相关推荐

0 条评论