PowerShell script exchange
Post Reply
Andreas Neufert
VP, Product Management
Posts: 6747
Liked: 1408 times
Joined: May 04, 2011 8:36 am
Full Name: Andreas Neufert
Location: Germany
Contact:

Andys scripting corner - Exit code to cmd handover

Post by Andreas Neufert »

Hi,

in addition to my other scripts you can handover the errorresultcounter ore another counter to a cmd that starts the powershell.

exit.cmd

Code: Select all

powershell -command "& { C:\exit\exit.ps1; exit $lastexitcode }" 
Echo %Errorlevel%”
You can add "pause" at the end if you want to see what happens.


exit.ps1

Code: Select all

$resultcounterend = "999"  # If you want to handover a number
# $Resultcounterend = $Resultcounter + $error.count # If you using my othe scripts
# $resultcounterend = $resultcounter # If you want to handover the nomal poweshell error level


Exit $resultcounterend
CU Andy
Post Reply

Who is online

Users browsing this forum: No registered users and 9 guests