Horrific problems trying to push out Powershell scripts with SCCM2007
I have tried everything I can think of and I can't get a darn Posh script to execute properly on my Win2K8 R2 servers. When I run the script manually/locally on those servers, the script runs fine. However, when I distribute a package/advertisement to those same servers, they always return an exit code of -1 indicating some kind of failure. The script I was originally using was setting some registry keys. However, I modified the package so that it was pushing out a powershell script that did NOTHING more than running a Get-Process and I still get errors. I've tried the following for the Program command-lines: - powershell.exe test.ps1 - %windir%\system32\WindowsPowerShell\v1.0\powershell.exe test.ps1 - C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe test.ps1 - Tried a batch file that executes powershell with my ps1 file as an argument for the batch and then, powershell.bat test.ps1 - Tried passing arguments to powershell executable: -noprofile, -nologo -executionpolicy unrestricted, -executionpolicy bypass -file None of them provide any different results. Execmgr.log on all three servers in the Collection all report back a generic execution error of -1. Does anyone have any idea of how I can fix this? Thanks! Execmgr.log Error: Content is available for program TEST - NIC TCP Offload Settings New. execmgr 9/9/2011 2:26:25 PM 4560 (0x11D0) CExecutionRequest::Service Windows Manager has allowed us to run. execmgr 9/9/2011 2:26:25 PM 4560 (0x11D0) Executing program powershell.exe test.ps1 in Admin context execmgr 9/9/2011 2:26:25 PM 4560 (0x11D0) Execution Manager timer has been fired. execmgr 9/9/2011 2:26:25 PM 5776 (0x1690) Execution Request for package TT100048 program TEST - NIC TCP Offload Settings New state change from WaitingContent to NotifyExecution execmgr 9/9/2011 2:26:25 PM 4560 (0x11D0) Checking content location C:\Windows\SysWOW64\CCM\Cache\TT100048.1.System for use execmgr 9/9/2011 2:26:25 PM 4560 (0x11D0) Successfully selected content location C:\Windows\SysWOW64\CCM\Cache\TT100048.1.System execmgr 9/9/2011 2:26:25 PM 4560 (0x11D0) GetFileVersionInfoSize failed for file C:\Windows\SysWOW64\CCM\Cache\TT100048.1.System\powershell.exe, error 2 execmgr 9/9/2011 2:26:25 PM 4560 (0x11D0) Executing program as a script execmgr 9/9/2011 2:26:25 PM 4560 (0x11D0) Found executable file powershell.exe with complete path C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe execmgr 9/9/2011 2:26:25 PM 4560 (0x11D0) Successfully prepared command line "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" test.ps1 execmgr 9/9/2011 2:26:25 PM 4560 (0x11D0) Command line = "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" test.ps1, Working Directory = C:\Windows\SysWOW64\CCM\Cache\TT100048.1.System\ execmgr 9/9/2011 2:26:25 PM 4560 (0x11D0) Created Process for the passed command line execmgr 9/9/2011 2:26:25 PM 4560 (0x11D0) Raising event: [SMS_CodePage(437), SMS_LocaleID(1033)] instance of SoftDistProgramStartedEvent { AdvertisementId = "TT120065"; ClientID = "GUID:BA2BAF3E-29DC-4768-A70D-42782AA9691A"; CommandLine = "\"C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe\" test.ps1"; DateTime = "20110909142625.553000+000"; MachineName = "TARGET_SERVER"; PackageName = "TT100048"; ProcessID = 5984; ProgramName = "TEST - NIC TCP Offload Settings New"; SiteCode = "TT1"; ThreadID = 4560; UserContext = "NT AUTHORITY\\SYSTEM"; WorkingDirectory = "C:\\Windows\\SysWOW64\\CCM\\Cache\\TT100048.1.System\\"; }; execmgr 9/9/2011 2:26:25 PM 4560 (0x11D0) Successfully submitted event to the Status Agent. execmgr 9/9/2011 2:26:25 PM 4560 (0x11D0) Raised Program Started Event for Ad:TT120065, Package:TT100048, Program: TEST - NIC TCP Offload Settings New execmgr 9/9/2011 2:26:25 PM 4560 (0x11D0) Policy arrived for parent package TT100048 program TEST - NIC TCP Offload Settings New execmgr 9/9/2011 2:26:25 PM 8100 (0x1FA4) Raising event: [SMS_CodePage(437), SMS_LocaleID(1033)] instance of SoftDistProgramOfferReceivedEvent { AdvertisementId = "TT120065"; ClientID = "GUID:BA2BAF3E-29DC-4768-A70D-42782AA9691A"; DateTime = "20110909142625.756000+000"; MachineName = "TARGET_SERVER"; ProcessID = 5984; SiteCode = "TT1"; ThreadID = 8100; }; execmgr 9/9/2011 2:26:25 PM 8100 (0x1FA4) Successfully submitted event to the Status Agent. execmgr 9/9/2011 2:26:25 PM 8100 (0x1FA4) Program exit code 1 execmgr 9/9/2011 2:26:26 PM 5776 (0x1690) Looking for MIF file to get program status execmgr 9/9/2011 2:26:26 PM 5776 (0x1690) Script for Package:TT100048, Program: TEST - NIC TCP Offload Settings New failed with exit code 1 execmgr 9/9/2011 2:26:26 PM 5776 (0x1690) Raising event: [SMS_CodePage(437), SMS_LocaleID(1033)] instance of SoftDistProgramErrorEvent { AdvertisementId = "TT120065"; ClientID = "GUID:BA2BAF3E-29DC-4768-A70D-42782AA9691A"; DateTime = "20110909142626.052000+000"; ExitCode = "1"; MachineName = "TARGET_SERVER"; PackageName = "TT100048"; ProcessID = 5984; ProgramName = "TEST - NIC TCP Offload Settings New"; SiteCode = "TT1"; ThreadID = 5776; UserContext = "NT AUTHORITY\\SYSTEM"; }; execmgr 9/9/2011 2:26:26 PM 5776 (0x1690) Successfully submitted event to the Status Agent. execmgr 9/9/2011 2:26:26 PM 5776 (0x1690) Raised Program Error Event for Ad:TT120065, Package:TT100048, Program: TEST - NIC TCP Offload Settings New execmgr 9/9/2011 2:26:26 PM 5776 (0x1690) Execution is complete for program TEST - NIC TCP Offload Settings New. The exit code is 1, the execution status is FailureNonRetry execmgr 9/9/2011 2:26:26 PM 4956 (0x135C) Policy is updated for Program: TEST - NIC TCP Offload Settings New, Package: TT100048, Advert: TT120065 execmgr 9/9/2011 3:28:21 PM 4856 (0x12F8) Script for Package:TT100049, Program: TEST - TCP Offload Settings Script (PowerShell) failed with exit code 1 execmgr 9/12/2011 6:26:43 PM 3120 (0x0C30)
September 12th, 2011 3:23pm

Have you set the PowerShell execution policy on the target systems?Jason | http://myitforum.com/cs2/blogs/jsandys | Twitter @JasonSandys
Free Windows Admin Tool Kit Click here and download it now
September 12th, 2011 3:51pm

Yes... again, I've run the script manually on all three systems in the collection and it runs as it should (both the original script and my basic get-process script). It's only when I run the script through SCCM that it fails. As a side note, we only have 1 other posh script we're pushing out through SCCM and it works (it sets the execution policy) but the significant difference is that it's invoking the -script parameter to supply the Set-ExecutionPolicy Unrestricted; so the actual code is inline instead of supplied by a file. Also, we are using Posh scripting in DCM but again, this is more of an inline method as opposed to supplying a secondary file.
September 12th, 2011 4:10pm

I would never have thought of this but one of my coworkers found the simple (yet confusing) solution: powershell.exe .\test.ps1 This seems odd to me with my (probably flawed) view of how SCCM executes a commandline and considering the ".\" is almost exclusively limited (AFAIK) to running things inside of powershell, I don't see why this would work. However, limited testing seems to indicate that this IS the fix. I'll post back with any updates/changes. Thanks!
Free Windows Admin Tool Kit Click here and download it now
September 12th, 2011 4:55pm

The above did not end up working (thankfully). It worked on the hosts where we'd manually run the script but not on newly added hosts to the targetted collection. What did end up working was a batch file using this this: powershell.exe -file %1 and the SCCM Program cmdline as: powershell.bat myPSFile.ps1 Sorry for the confusion. This has worked on all of my win2k8 boxes...
September 14th, 2011 3:16pm

You saved my Day! That does the trick! I am wondering if that is another 32bit on 64bit circumstance. Looking forward to ConfigMgr2012 to get a native 64 bit sccm client... THX
Free Windows Admin Tool Kit Click here and download it now
April 19th, 2012 4:54am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics