Get-ADGroup GROUPNAME | %{$gr = $_; Get-ADGroupMember -Identity $gr | %{$u = get-aduser $_; if (($u.enabled -eq $false) -and ($u.DistinguishedName -like "*lock*")){write-host $u.name $u.DistinguishedName; Remove-ADGroupMember -identity $gr $u -Confirm:$false}}}