Quantcast
Channel: Scripting Blog
Viewing all articles
Browse latest Browse all 2129

PowerTip: Capture error code of a PowerShell session in Linux or macOS

$
0
0

Summary: Capture the status code of a PowerShell session in Linux or macOS.

Hey, Scripting Guy! Question Could you show me how to run a PowerShell script in Linux or macOS and capture the status of whether that script succeeded or failed?

Hey, Scripting Guy! Answer No problem, my friend. Just run the PowerShell session, and start the script as in the following example. You can view the status in the $? built-in variable in Linux and macOS.

powershell -file ./samplescript.ps1

echo $?

The Doctor


Viewing all articles
Browse latest Browse all 2129

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>