Last active
March 29, 2019 16:54
-
-
Save AlexFilipin/7a8aba107346984ad1418d79c69eb67d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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