Import-Module ActiveDirectory While (($user = Read-Host "Username (leave blank to exist)") -ne "") { $groupfilter = Read-Host "Group name must contain (leave blank for all)" $groupadd = Read-Host "Add user to group (leave blank to not attempt add)" If ($groupadd -ne "") { Write-Host "" Try { Add-ADGroupMember -Identity $groupadd -Members $user Write-Host $user "successfully added to" $groupadd } Catch { Write-Host $Error } } $groups = Get-ADPrincipalGroupMembership $user | Sort Name Write-Host "" Write-Host "Groups added within the last couple minutes may not list." Write-Host "" ForEach ($group in $groups) { If($group.Name -match $groupfilter) {Write-Host $group.Name} } Write-Host "" }