过滤并更改我所有用户的使用位置 - 脚本 powershell 或 Ms Graph

问题描述 投票:0回答:1

创建 MS Graph 或 powershell 脚本,将所有用户的“使用位置”更改为“CA”

我能够为一名用户执行此操作,但我想为所有用户执行此操作

$userId = '00000000000000'
$usageLocation = 'IN'

Update-MgUser -UserId $userId -Usagelocation $usageLocation
azure-powershell
1个回答
0
投票

创建 MS Graph 或 powershell 脚本,将所有用户的“使用位置”更改为“CA”

要使用图形模块将用户使用位置更新为加拿大,您可以使用以下脚本:

脚本

Connect-MgGraph

# Get all users
$users = Get-MgUser -All 

# Update the usage location for each user
foreach ($user in $users) {
    Update-MgUser -UserId $user.Id -UsageLocation "CA"
}

上述脚本将连接到 Microsoft Graph,获取所有用户,然后将每个用户的使用位置更新为我的环境中的“CA”。

输出:

enter image description here

参考:

Microsoft.Graph.Users 模块 |微软学习

© www.soinside.com 2019 - 2024. All rights reserved.