Skip to content

Instantly share code, notes, and snippets.

@AlexFilipin
Last active March 29, 2019 16:54
Show Gist options
  • Save AlexFilipin/7a8aba107346984ad1418d79c69eb67d to your computer and use it in GitHub Desktop.
Save AlexFilipin/7a8aba107346984ad1418d79c69eb67d to your computer and use it in GitHub Desktop.
param(
[string]$Path
)
$Data = Import-Csv $Path -Delimiter ";"
foreach($Item in $Data){
if($Item.Operation -eq "Replace"){
if($Item.Values -eq "True"){$Item.Values = $true}
if($Item.Values -eq "False"){$Item.Values = $false}
Set-ADUSer -Identity $Item.DN -Replace @{$Item.Name=$Item.Values}
}
if($Item.Operation -eq "ReplaceMV"){
$Values = $Item.Values.Split("|")
Set-ADUSer -Identity $Item.DN -Clear $Item.Name
foreach($Value in $Values){
Set-ADUSer -Identity $Item.DN -Add @{$Item.Name=$Value}
}
}
if($Item.Operation -eq "Clear"){
Set-ADUSer -Identity $Item.DN -Clear $Item.Name
}
if($Item.Operation -eq "RemoveAccount"){
Remove-ADUser -Identity $Item.DN
}
if($Item.Operation -eq "Move"){
Move-ADObject -Identity $Item.DN -TargetPath $Item.Values
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment