Asked by:
changing multiple attributes of users

General discussion
-
Hello,
i have list of cSv file of users , i am importing the file and for these users i am actually clearing some attributes and somehow its working fine, but i want to clear multiple attributes in one command , but once i am trying to put multiple attributes one its taking first one and ignoring reaming, pls help me
Import-Module ActiveDirectory
Import-Csv "C:\temp\old-lync.csv" | ForEach-Object {
$samAccountName = $_."samAccountName"
Get-ADUser -Identity $samAccountName |
Set-ADUser -Clear “msRTCSIP-OptionFlags”;,“msRTCSIP-PrimaryUserAddress”;,“msRTCSIP-UserEnabled”;, “msRTCSIP-UserPolicies”;,“msRTCSIP-UserRoutingGroupId”;,“msRTCSIP-PrimaryHomeServer”; “Cleaned $($_)”}Sunday, January 21, 2018 9:09 AM
All replies
-
I used it to test, it appears to clear multiple attributes:
Get-ADObject $users[0] -properties othermobile,company | Set-ADUser -Clear othermobile,company
You are specifying only list properties(array) and not hash-table. why have you used ';' and ',' together?
Ketan Thakkar | Microsoft Online Community Support
Sunday, January 21, 2018 3:30 PM -
BTW, someone has already tried working with similar (office communication server) set of attributes:
https://powershell.org/forums/topic/clear-multi-attribute-with-content-for-ad-users/
Ketan Thakkar | Microsoft Online Community Support
Sunday, January 21, 2018 3:33 PM -
Why are you using so man semicolons? Look closely at you code. It cannot work. Semicolons at like statement terminators.
\_(ツ)_/
Sunday, January 21, 2018 4:23 PM -
Also what is "Cleaned $($_)”? I cannot be the name of an attribute.
$attributes = @( 'msRTCSIP-OptionFlags', 'msRTCSIP-PrimaryUserAddress' , 'msRTCSIP-UserEnabled' , 'msRTCSIP-UserPolicies' , 'msRTCSIP-UserRoutingGroupId' , 'msRTCSIP-PrimaryHomeServer' ) Import-Csv C:\temp\old-lync.csv | ForEach-Object { Set-ADUser -Identity $_.samAccountName -Clear $attributes }
\_(ツ)_/
- Edited by jrv Sunday, January 21, 2018 4:30 PM
Sunday, January 21, 2018 4:29 PM -
this one worked for me , may be other also correct but i couln;t try al.
$attributes = @( 'msRTCSIP-OptionFlags', 'msRTCSIP-PrimaryUserAddress' , 'msRTCSIP-UserEnabled' , 'msRTCSIP-UserPolicies' , 'msRTCSIP-UserRoutingGroupId' , 'msRTCSIP-PrimaryHomeServer' ) Import-Csv C:\temp\old-lync.csv | ForEach-Object { Set-ADUser -Identity $_.samAccountName -Clear $attributes }
Monday, January 22, 2018 5:00 AM