Office 365 管理系列:升級通訊群組為群組之後的 PowerShell 命令變化...
source link: https://blog.miniasp.com/post/2020/12/07/Office-365-Administration-PowerShell-cmdlet-changes-after-Upgrade-Distribution-List-DL-to-Group
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
前陣子 Office 365 管理介面建議我將「通訊群組」(Distribution List) (DL) 全面升級為「群組」(Group),但我在升級完成後,我現有的 PowerShell 命令就失效了,因為 Cmdlet 命令不一樣了,這篇文章來說說其差異之處。
以下是我原本的 PowerShell 命令,先連到 MSOnline 服務、再建立帳號、然後設定預設密碼,等待 120 秒之後,才能將帳號加入到「通訊群組」之中,最後設定直屬主管是誰:
Connect-MsolService
New-MsolUser -UserPrincipalName $UserPrincipalName -DisplayName $DisplayName -FirstName $FirstName -LastName $LastName -UsageLocation $UsageLocation -LicenseAssignment $LicenseAssignment -MobilePhone $MobilePhone -Office $Office -PhoneNumber $PhoneNumber -PreferredLanguage $PreferredLanguage -State $State -StreetAddress $StreetAddress -Title $Title -AlternateEmailAddresses $AlternateEmailAddresses -Country $Country -PostalCode $PostalCode -City $City -Department $Department -Fax $Fax
Set-MsolUserPassword -UserPrincipalName $UserPrincipalName -NewPassword YouRVeryC0mplexPw
#Set-MsolUser -UserPrincipalName $UserPrincipalName -DisplayName "$LastName" + "$FirstName" + "David"
# 可能要等 2 分鐘才能設定
Start-Sleep -Seconds 120
Add-DistributionGroupMember -Identity "all" -Member $UserPrincipalName
Set-User $UserName -Company $CompanyName -Manager will
由於我的「通訊群組」已經都全面升級為「群組」了,所以關於 Add-DistributionGroupMember 就必須全面修改為 Add-UnifiedGroupLinks 才行,但參數的用法不太一樣,你必須修改成以下命令:
Add-UnifiedGroupLinks -Identity "all" -LinkType "Members" -Links $UserPrincipalName
all
是「群組」的 Identity 名稱-LinkType
可以是Members
、Owners
或Subscribers
-Links
則可以放入你想加入的使用者
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK