Powershell.exe will return an exit code for the script when you use the -command or -file parameter.
How are you calling PowerShell? I have a few provisioning scripts written in PowerShell that I use the Kace KBOX agent to run. Syntax is very similar to this blog: http://blogs.msdn.com/b/powershell/archive/2006/10/14/windows-powershell-exit-codes.aspx The blog just runs a command, but with -file you can call a script. You can also set the exit codes by making the last command or line "exit ##" where ## is the code you want to return. Regards, Joe From: Christopher Bodnar [mailto:[email protected]] Sent: Friday, April 01, 2011 3:17 PM To: NT System Admin Issues Subject: PowerShell scripts in PrimalScript Windows Server 2008 R2 SP1 PrimalScript 2009 version 5.0.644 OK, if I run a PS script in PrimalScript, and it completes successfully, should I seen an exit code like I do with a VBScript? Right now it looks like PowerShell is still running after the script completes. I need to manually terminate it (Script -> Stop Script). Just doing something as basic as a process list: GET-PROCESS Same results. Like PowerShell just doesn't know to terminate. I've loaded it on another machine (Windows Server 2003 SP2) with the exact same results. I'm thinking this is just a configuration issue on my side, but I'm not sure what? Something with my PowerShell profile? Also if I launch PowerShell separately, and run a script everything is fine. This is just inside PrimalScript. Thanks, Chris Bodnar, MCSE, MCITP Technical Support III Distributed Systems Service Delivery - Intel Services Guardian Life Insurance Company of America Email: [email protected]<mailto:[email protected]> Phone: 610-807-6459 Fax: 610-807-6003 ----------------------------------------- This message, and any attachments to it, may contain information that is privileged, confidential, and exempt from disclosure under applicable law. If the reader of this message is not the intended recipient, you are notified that any use, dissemination, distribution, copying, or communication of this message is strictly prohibited. If you have received this message in error, please notify the sender immediately by return e-mail and delete the message and any attachments. Thank you. ~ Finally, powerful endpoint security that ISN'T a resource hog! ~ ~ <http://www.sunbeltsoftware.com/Business/VIPRE-Enterprise/> ~ --- To manage subscriptions click here: http://lyris.sunbelt-software.com/read/my_forums/ or send an email to [email protected]<mailto:[email protected]> with the body: unsubscribe ntsysadmin ~ Finally, powerful endpoint security that ISN'T a resource hog! ~ ~ <http://www.sunbeltsoftware.com/Business/VIPRE-Enterprise/> ~ --- To manage subscriptions click here: http://lyris.sunbelt-software.com/read/my_forums/ or send an email to [email protected] with the body: unsubscribe ntsysadmin
