18 lines
1.8 KiB
Markdown
18 lines
1.8 KiB
Markdown
# Change_AD_Custom_Attributes
|
|
|
|
List or change custom Active Directory attributes
|
|
|
|
<code>
|
|
#List attribute(s) from a csv list of users
|
|
Import-Csv -Path C:\Users\22306-a\Desktop\<My_CSV>.csv | `
|
|
foreach {if ((Get-ADUser -Identity $_.'User ID' -Properties <CUSTOM_ATTRIBUTE> | select <CUSTOM_ATTRIBUTE>) -like "*<VALUE>*") {Get-ADUser -Identity $_.'User ID' -Properties <CUSTOM_ATTRIBUTE> | select <CUSTOM_ATTRIBUTE>} `
|
|
elseif ((Get-ADUser -Identity $_.'User ID' -Properties <CUSTOM_ATTRIBUTE> | select <CUSTOM_ATTRIBUTE>) -like "*<VALUE>*") {Get-ADUser -Identity $_.'User ID' -Properties <CUSTOM_ATTRIBUTE> | select <CUSTOM_ATTRIBUTE>} `
|
|
elseif ((Get-ADUser -Identity $_.'User ID' -Properties <CUSTOM_ATTRIBUTE> | select <CUSTOM_ATTRIBUTE>) -like "*<VALUE>*") {Get-ADUser -Identity $_.'User ID' -Properties <CUSTOM_ATTRIBUTE> | select <CUSTOM_ATTRIBUTE>}}
|
|
|
|
|
|
#set attribute(s) from a csv list of users
|
|
Import-Csv -Path C:\Users\22306-a\Desktop\ChangeVP.csv | `
|
|
foreach {if ((Get-ADUser -Identity $_.'User ID' -Properties <CUSTOM_ATTRIBUTE> | select <CUSTOM_ATTRIBUTE>) -like "*<VALUE>*") {Set-ADUser -Identity $_.'User ID' -replace @{<CUSTOM_ATTRIBUTE>="<VALUE>"} | Get-ADUser -Identity $_.'User ID' -Properties <CUSTOM_ATTRIBUTE> | select <CUSTOM_ATTRIBUTE>} `
|
|
elseif ((Get-ADUser -Identity $_.'User ID' -Properties <CUSTOM_ATTRIBUTE> | select <CUSTOM_ATTRIBUTE>) -like "*<VALUE>*") {Set-ADUser -Identity $_.'User ID' -replace @{<CUSTOM_ATTRIBUTE>="<VALUE>"} | Get-ADUser -Identity $_.'User ID' -Properties <CUSTOM_ATTRIBUTE> | select <CUSTOM_ATTRIBUTE>} `
|
|
elseif ((Get-ADUser -Identity $_.'User ID' -Properties <CUSTOM_ATTRIBUTE> | select <CUSTOM_ATTRIBUTE>) -like "*<VALUE>*") {Set-ADUser -Identity $_.'User ID' -replace @{<CUSTOM_ATTRIBUTE>="<VALUE>"} | Get-ADUser -Identity $_.'User ID' -Properties <CUSTOM_ATTRIBUTE> | select <CUSTOM_ATTRIBUTE>}}
|
|
</code> |