4

如何批次修改 Microsoft 365 所有成員的聯絡地址

 2 years ago
source link: https://blog.miniasp.com/post/2021/12/03/Batch-updating-Microsoft-365-user-account-properties
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.

如何批次修改 Microsoft 365 所有成員的聯絡地址

最近我們公司搬遷到新的地址,公司所有 Microsoft 365 帳號下的地址也要進行更新,所以就寫了個 PowerShell 腳本來批次更新大家的地址資訊。

  1. 列出所有同仁的地址資訊

    
    Get-AzureADUser | Sort UserPrincipalName | where { $_.UserType -eq 'Member' } | Select UserPrincipalName,DisplayName,PostalCode,Country,State,City,StreetAddress | Format-Table
    
    
  2. 取得一位同仁的地址資訊

    
    $userPrincipalName="[email protected]"
    Get-AzureADUser | where { $_.UserPrincipalName -eq $userPrincipalName } | Select UserPrincipalName,DisplayName,PostalCode,Country,State,City,StreetAddress
    
    
  3. 更新所有同仁的地址資訊

    
    $PostalCode        = "10444"
    $Country           = "TW"
    $State             = "台灣"
    $City              = "台北市"
    $StreetAddress     = "中山北路一段82號7樓"
    
    Get-AzureADUser | Sort UserPrincipalName | where { $_.UserType -eq 'Member' } | Set-AzureADUser -PostalCode $PostalCode -Country $Country -State $State -City $City -StreetAddress $StreetAddress
    
    
  4. 更新一位同仁的地址資訊

    
    $userPrincipalName  = "[email protected]"
    
    $PostalCode         = "10444"
    $Country            = "TW"
    $State              = "台灣"
    $City               = "台北市"
    $StreetAddress      = "中山北路一段82號7樓"
    
    Get-AzureADUser | where { $_.UserPrincipalName -eq $userPrincipalName } | Set-AzureADUser -PostalCode $PostalCode -Country $Country -State $State -City $City -StreetAddress $StreetAddress
    
    

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK