简体   繁体   中英

Error when changing AD properties in Powershell

Trying to change msexchhidefromaddresslists property from Powershell for a specific user account. I did a search and found a basic script but am getting an error. I have tried directly from my system and fromm the server. Any ideas?

set-aduser ldap -replace @{msexchhidefromaddresslists="$true"}


set-aduser : The parameter is incorrect
At line:1 char:1
+ set-aduser ldap -replace @{msexchhidefromaddresslists="$true"}
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (ldap:ADUser) [Set-ADUser], ADInvalidOperationException
    + FullyQualifiedErrorId : ActiveDirectoryServer:87,Microsoft.ActiveDirectory.Management.Commands.SetADUser

The schema for the msExchHideFromAddressLists attribute specifies oMSyntax: 1 , or Boolean .

LDAP allows a couple different representations of booleans, including integral values ( 0 for false , a non-zero value for true ), or, more commonly the lower-case string representations true or false .

"$true" , on the other hand, results in a string with value True (notice it's title-cased, not lowercase).

Use one of:

  • @{msExchHideFromAddressLists = 1}
  • @{msExchHideFromAddressLists = "true"} or
  • @{msExchHideFromAddressLists = $True}

In the last case, the $true value will be (correctly) translated by ADWS, rather than (incorrectly) by PowerShell's string conversion logic

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM