admin管理员组文章数量:1332339
I am trying to run a PowerShell script to change all UPNs in a specific OU to lowercase, but I am not having any success. Based on some previous posts and using the same command I use to change other attributes successfully, I am trying the following:
Get-ADUser -Filter * -SearchBase "OU=[REDACTED]"
| Set-ADUser -replace @{userPrincipalName=userPrincipalName.ToLower}
But when I run this I am getting an error
'userPrincipalName.ToLower' is not recognized
I have also tried adding ()
to the end of ToLower
, but with the same result.
Any suggestions would be greatly appreciated. Thank you for your time.
I am trying to run a PowerShell script to change all UPNs in a specific OU to lowercase, but I am not having any success. Based on some previous posts and using the same command I use to change other attributes successfully, I am trying the following:
Get-ADUser -Filter * -SearchBase "OU=[REDACTED]"
| Set-ADUser -replace @{userPrincipalName=userPrincipalName.ToLower}
But when I run this I am getting an error
'userPrincipalName.ToLower' is not recognized
I have also tried adding ()
to the end of ToLower
, but with the same result.
Any suggestions would be greatly appreciated. Thank you for your time.
Share Improve this question edited Nov 20, 2024 at 20:33 marc_s 756k184 gold badges1.4k silver badges1.5k bronze badges asked Nov 20, 2024 at 20:17 AA27CXPAA27CXP 135 bronze badges1 Answer
Reset to default 1You're missing a loop in your code to get the pipped user's UserPrincipalName
, add ForEach-Object
and reference it via $_.UserPrincipalName
, then you can .ToLower()
it:
Get-ADUser -Filter * -SearchBase 'OU=[REDACTED]' | ForEach-Object {
Set-ADUser -Identity $_ -UserPrincipalName $_.UserPrincipalName.ToLower()
}
本文标签: active directoryHaving trouble making UserPrincipalName all lowercase in PowershellStack Overflow
版权声明:本文标题:active directory - Having trouble making UserPrincipalName all lowercase in Powershell - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742331534a2454792.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论