【问题标题】:how to update UsageLocation of AD User using powershell如何使用 powershell 更新 AD 用户的 UsageLocation
【发布时间】:2020-08-31 21:38:53
【问题描述】:

我正在尝试使用 powershell 更新 AD 用户的 UsageLocation,以便我可以为其分配 O365 许可证。

基于this

您可以通过 Active Directory 中的“msExchUsageLocation”属性填充“UsageLocation”

我修改并执行了这个code

Get-AdUser -identity "IReyna" | Set-AdUser -replace @{msExchUsageLocation="US"}

但是它会引发错误:

Embedded message: can't parse argument number: msExchUsageLocation="US";  
Caused by: For input string: "msExchUsageLocation="US""

我真的不知道从这里去哪里。

更新: 代码上下文位于 Boomi 环境中(即运行 Powershell 脚本)。我只需要转义大括号,因为它们是为参数保留的(即{1})。

powershell -Command "Get-AdUser -identity \"IReyna\" | Set-AdUser -replace @'{'msExchUsageLocation=\"US\"'}'"

【问题讨论】:

  • 该命令在我的域上运行良好。检查您的 Powershell 版本,您的 AD 对象是否有该属性可用?
  • 一切正常,也感谢您的确认

标签: powershell active-directory office365 boomi


【解决方案1】:

问题在于双引号使用单引号,例如msExchUsageLocation='美国'

【讨论】:

  • 您能否添加一些文档或说明为什么这会解决该错误?
猜你喜欢
  • 2015-06-15
  • 1970-01-01
  • 2018-12-23
  • 1970-01-01
  • 2019-02-08
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多