Kevin Marquette explains what is possible with if in Powershell:
The
-notoperator flips an expression from$falseto$trueor from$trueto$false. Here is an example where we want to perform an action whenTest-Pathis$false.if ( -not ( Test-Path -Path $path ) )
There’s plenty of good stuff here, so check it out.