更新AD用户国家/地区的脚本 [英] Script to update AD User Country
问题描述
你好,
我是PowerShell的新手,我正在努力自学,所以请保持温和
我正在尝试使用powershell更新我的AD用户的国家/地区代码。在大多数用户案例中,这是空白的。我已经确定AD属性是< countrycode>英国的价值是826.所以我认为代码应该类似于
get-ADUser -countrycode" null" | set-ADUser -countrycode" 826"
Powershell不喜欢这样,并且get-help set-user似乎不会将countrycode识别为属性。
TIA,
Rich
使用-Replace Set-ADUser的参数。另外,为了测试是否缺少属性值,您可以使用-LDAPFilter"(!countryCode = *)"
get-ADUser -LDAPFilter"(! COUNTRYCODE = *)" | set-ADUser -Replace @ {countrycode = 826}
此外,由于countryCode是32位整数,因此不应引用它。
Hi there,
I am a PowerShell newb and am trying to teach myself so please be gentle
I am trying to use powershell to update the country code of my AD users. This is blank in most users case. I have identified that the AD attribute is <countrycode> and the value for UK is 826. so I think the code should be something like
get-ADUser -countrycode "null" ¦ set-ADUser -countrycode "826"
Powershell doesn't like this and get-help set-user does not seem to recognise countrycode as an attribute.
TIA,
Rich
Use the -Replace parameter of Set-ADUser. Also to test if an attribute value is missing, you can use -LDAPFilter "(!countryCode=*)"
get-ADUser -LDAPFilter "(!countrycode=*)" | set-ADUser -Replace @{countrycode=826}
Also, since countryCode is a 32-bit integer, it should not be quoted.
这篇关于更新AD用户国家/地区的脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!