|
Hi!
I haven't yet looked at your code, but beware that SCOM might be executing the powershell code with a different version of powershell, than when you execute it 'online'. That is something that has changed with scom 2012 UR8
/Henrik
-------- Oprindelig meddelelse -------- Fra: "Orlebeck, Geoffrey" <[email protected]> Dato: 06/11/2015 18.54 (GMT+01:00) Til: "'[email protected]'" <[email protected]> Emne: [msmom] PowerShell Script Inconsistent Behavior I’m having an issue that I have not run into before.
I have one MP where I have a module setup to run a PowerShell script every 5mins. The script is supposed to grab all PDFs in a folder and depending on size/age/matching XML, be copied/moved to several directories. I’ve now run it dozens of times manually without a single issue. However, when I wrap it up in a SCOM monitor, it sometimes (but not always)copies the actual PDF directory into the target directory for the move. I setup some logging inside the PowerShell script and it appears to not match the script criteria (or the parameters are being mangled). I’m wondering if anyone has run into a similar issue? Here are the two log entries.
Manual Execution: ======================================================================== 11/06/2015 09:26:41 | Processing Started: Good_File.pdf 11/06/2015 09:26:41 | Good_File.pdf is 209KB 11/06/2015 09:26:41 | XML pair found: Good_File.xml 11/06/2015 09:26:41 | Good_File.pdf copy to C:\Folder\Prod\PDF\Archive success 11/06/2015 09:26:41 | Good_File.pdf move to C:\Program Files (x86)\Acme\Outbound success 11/06/2015 09:26:41 | Processing Complete: Good_File.pdf 11/06/2015 09:26:41 | Good_File.xml copy to C:\Folder\Prod\PDF\Archive success 11/06/2015 09:26:41 | Good_File.xml move to C:\Program Files (x86)\Acme\Outbound success 11/06/2015 09:26:41 | Processing Complete: Good_File.xml ========================================================================
SCOM Execution: ======================================================================== 11/05/2015 21:26:59 | Processing Started: 11/05/2015 21:26:59 | is 0KB 11/05/2015 21:26:59 | XML pair found: .xml 11/05/2015 21:26:59 | Processing Complete: 11/05/2015 21:26:59 | .xml copy to C:\Folder\Prod\PDF\Archive failed 11/05/2015 21:26:59 | .xml move to C:\Program Files (x86)\Acme\Outbound failed 11/05/2015 21:26:59 | Processing Complete: .xml ========================================================================
When executing via SCOM there are random instances where the PDF folder in C:\Folder\Prod is being moved to C:\Program Files (x86)\Acme\Outbound:
I cannot reproduce this when executing my script manually; I only see it when run via SCOM. The difference with manual is I am defining the variables within my PS session ($directory, $errordir, etc.) prior to running the script. With SCOM, the parameters are supposed to be passed in so I don’t have to hard code them in the PowerShell script (per Brian Wren’s training videos). I am attaching the test MP I am using for this. If there are any insight, I’m really interested to know if there is an issue/limitation related to PowerShell/SCOM I need to account for or if it’s a problem with my MP authoring.
Thank you very much.
Geoff
|
- [msmom] PowerShell Script Inconsistent Behavior Orlebeck, Geoffrey
- RE: [msmom] PowerShell Script Inconsistent Behavio... Henrik Andersen
- RE: [msmom] PowerShell Script Inconsistent Behavio... Orlebeck, Geoffrey
- RE: [msmom] PowerShell Script Inconsistent Behavio... Henrik Andersen
