Exit out of a PowerShell script

User avatar
daniel
Site Admin
Posts: 223
Joined: Tue Jan 09, 2007 9:54 pm
Contact:

Exit out of a PowerShell script

Postby daniel » Fri Apr 15, 2011 11:47 am

Exit out of a PowerShell script when using a check is best done as follow:

Code: Select all

If (-not (Test-Path -eq "Myfile"))
{
#Don't do something
exit
}


Other options are break and goto but these have other area's in which the best fit.

Return to “PowerShell”

Who is online

Users browsing this forum: No registered users and 1 guest