Good afternoon, all.
I am trying to perform a search in P/S for SamAccountName that contains / starts with "svc_", and does not belong to a group called "disconnected", and write that to an Excel file.
What I am trying, at least for the syntax, doesn't result in anything. I know there are 300+ accounts that should show.
What am I declaring wrong?
get-aduser -filter * -properties *|? {$_.samaccountname -like "svc_" -and $_.MemberOf -eq "disconnected"}
I am also looking to do the same for those SamAccountName results that are not part of a group. I thought "-neq" would work (not equal), but I guess that value is wrong?
get-aduser -filter * -properties *|? {$_.samaccountname -like "svc_" -and $_.MemberOf -neq "disconnected"}
Once my mistakes are figured out, I will add | Export-Csv -Path $CSVfile -NoTypeInformation
to have it write to a csv file.
Thank you in advance for all the assistance.