I am trying to script a little application that would make possible to copy AD user's security groups and paste them to another one's profile.
I am good with this part but I want to make it a little bit more difficult by implementing some input boxes that would search for the AD user, errors out in case it does not exit in my AD and prompt once again until user has been found.
ipmo activedirectory
Add-type -assemblyName Microsoft.VisualBasic
Add-Type -AssemblyName System.Windows.Forms
$userref = [Microsoft.VisualBasic.Interaction]::Inputbox("Enter username
", "Prime User")
$usertar = [Microsoft.VisualBasic.Interaction]::Inputbox("Enter username",
"Target")
$userref, $usertar | foreach {
if ([bool](Get-ADUser -Filter {samaccountname -eq $_}) -ne $true) {
[System.Windows.Forms.MessageBox]::Show("This user does not exist!")
}
else {Write-Host "User Ok"}
}