I have a script that is currently working. There are two groups that need to be omitted from the CSV that is exported. As it currently sits it works. see below:
Import-Csv -Path .importactiveusers.csv | ForEach-Object{
$user = get-aduser -Identity $_.samaccountname -Properties name, samaccountname, memberof
$(
if ($user.memberof.count -gt 1) {
foreach ($group in $user.MemberOf -notlike "*groupname*") {
$user | select name, samaccountname,@{n='User Group';e={($_.memberof -like “*Certifiers-*” -
replace '^CN=(?.*?),(?:OU|CN).*$', '${Name}' -join ', ')}}, @{n='group';e={$group -
replace '^CN=(? .*?),(?:OU|CN).*$', '${Name}' -join ', '}}, @{n='Group Description';e=
{(Get-ADGroup $group -Properties description).description}},@{n='Date of File';e={(Get-date -
format M/d/yyy)}}
}}
)
}| Export-Csv -path 'C:UsersadiazADUserAccessList.csv' -NoTypeInformation
in the foreach line I have -notlike “groupname” i need to ad another group name to his that gets omitted. But when I do it does not return any results. What would be teh best way to go about this?