Can someone tell me why -or or not working. If I run the code, the first exit is an administrator who returns true, but when he gets to the kahuna account, he still returns false, not true.
(Get-LocalUser).Name | Out-File C:\localusers.txt
ForEach ($User in Get-Content C:\localusers.txt)
{
If ($User -match "administrator" -or "kahuna")
{
Write-Host True
}
Else
{
Write-Host False
}
}
I get
True, False, False, False, False
The following are the accounts displayed in the order they appear.
Admin, DefaultAccount, Guest, Kahuna, PCUser
source
share