mardi 27 février 2018

Powershell IF and not condition not working properly

I'm struggling to have two conditions met, somehow it seems only one of them works. I'm trying to do :

If a user is connected AND NOT at the lock screen, do something. The commands themselves have been verified and work individually but I must be missing something. Here is what i have:

if (Get-WmiObject –ComputerName $poste –Class Win32_ComputerSystem | Select-Object -expandproperty UserName -and -not (get-process -ComputerName $poste -name logonui)) {

do something...

}

Right now it just doesn't go in this code, it skips to the lower part where something else is happening.

What is wrong with my syntax ? Thank you for your time!

Aucun commentaire:

Enregistrer un commentaire