I would like to prevent my script from running if 'foobar.exe' is not in the correct location. I.E. 'C:\path\to\Foobar.exe'
I have tried #Requires -Assembly 'path\to\Foobar.exe'
but it throws an error
The error is unclear as to how to resolve this.
If I can't use #Requires
is there a different way to prevent the script from running if its 'Foobar.exe' is not in path\to
.
Just put this at the start of the script?
If (-not (Test-Path -Path 'C:\Path\To\foo.exe')) {
Throw "Cannot find 'C:\Path\To\foo.exe'"
}