Andys scripting corner - Exit code to cmd handover

PowerShell script exchange

Andys scripting corner - Exit code to cmd handover

Veeam Logoby Andreas Neufert » Fri Aug 17, 2012 7:48 am

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
Andreas Neufert
Veeam Software
 
Posts: 2201
Liked: 360 times
Joined: Wed May 04, 2011 8:36 am
Location: Germany
Full Name: @AndyandtheVMs Veeam PM

Return to PowerShell



Who is online

Users browsing this forum: No registered users and 7 guests