# Run the script
.\my-script.ps1
# Check the exit code
if ($LASTEXITCODE -eq 0) {
# Script was successful
Write-Host "The script ran successfully"
} else {
# Script failed
Write-Host "The script failed with exit code $LASTEXITCODE"
}
but there are other considerations for error handling https://thinkpowershell.com/powershell-error-handling-techniques/