HI all,
need your help to get this code running untill i enter right user
This loop is working just for one user
this is the full script
While (!$SourceUser) {
$copyfrom = Read-Host -Prompt “Copy Groups From”
Try {
$SourceUser = Get-ADUser -Identity $copyfrom -Properties memberof
}
Catch {
$copyfrom = Read-Host -Prompt "User not found. Please enter a user to copy groups from"
}
}
$SourceUser = Get-ADUser -Identity $copyfrom -Properties memberof
$SelectedGroups = $SourceUser.memberof |
Add-ADGroupMember -Members $username -PassThru |
Select-Object -ExpandProperty Name
any other idea?