I have a string with all users of the domain, and another with folder permissions (Groups/Users).
I need help with the if statement in my code, it needs to know if any user of the domain is in the string of the Groups/Users that have access to the folder.
if ($allusers -like "DOMAIN\*") {
$ws.Cells.Item($row, 3).Interior.ColorIndex = 3
Write-Host "true"
} else {
$ws.Cells.Item($row, 3).Interior.ColorIndex = 0
write-Host "false"
}
Example of strings:
Folder permissions:
DOMAIN\User1 Allow -- Modify, Synchronize DOMAIN\---- Allow -- ReadAndExecute, Synchronize DOMAIN\---- Allow -- Modify, Synchronize DOMAIN\---- Allow -- Modify, Synchronize
User list:
User1 User2 User3
The users come from:
$allusers = Get-ADUser -Filter * -SearchBase "dc=DOMAIN,dc=de" | select Samaccountname
And the permissions come from:
$OrdnerAccess = $Folder | Get-Acl | select AccessToString
They should both be lists if I'm not mistaken.
select -Expand <property>
to make them lists of strings. – Ansgar Wiechers