This if statement doesn't match anything for some reason even though the output in the CSV has the data $MemberName in the cell.
if($MemberName -notlike "Administrator" -or $MemberName -notlike "Domain Admins" -or $MemberName -notlike "Workstation Admin"){
Add-Content -Path $OutPutFile -Value "$Computer, $LocalGroupName, SUCCESS, $MemberType, $MemberDomain, $MemberName"
}
Also is there a more effeciet way to write the if statement? I only want to add the row IF the $MemberDomain and $MemberName DON'T MATCH the following sets of criteria:
$MemberDomain $MemberName
LocalUser AND Administrator
DomainGroup AND Workstation Admin
DomainGroup AND Domain Admins
Somethinng like:
if(($MemberName -notlike "Administrator" -and $MemberDomain -notlike "LocalUser") -or ($MemberName -notlike "Domain Admins" -and $MemberDomain -notlike "DomainGroup") -or ($MemberName -notlike "Workstation Admin" -and $MemberDomain -notlike "DomainGroup")) { do something }
Aucun commentaire:
Enregistrer un commentaire