I saw the article entitled "Can the Orion APM Windows PowerShell Monitor run PowerShell scripts in 64bit mode?" on the Knowledge Base and it got me thinking because there was definitely something missing. I grabbed it and started to play around with a few things and I have something that I think I'd like to share with everyone.
At the end of this is the vbScript I ended up authoring which can be pasted into the APM's "Windows Script Monitor" field. It's been tested (at least by me) and I've commented it pretty well in case anyone has any questions.
The advantage to this script as opposed to the one in the above article is that this one includes an optional debug output to help diagnose what "actually" is trying to be run, and it takes as many parameters as you like. The only required parameter is the file path to the script itself (for which it error traps). Otherwise you do not need to pass additional parameters.
Same rules regarding parameters apply as to those with file paths: if you need to include spaces, you'll need to double-quote the entire string of the parameter. Just below, you will see how this "works" if you use the Debug flag set to "true."
Notice that you get an error, but the message also returns the PowerShell Launch Command. Basically, you can just take this command (in my example starting with %SystemRoot% and going to the end of the red characters) and paste it in a command prompt window on the server running Orion NPM. What you get back in the Command Prompt expect to get back from APM when you set the debug flag to "false."
I would LOVE feedback, so if you have something you'd like to share, please feel free to do so!
The script is attached to this article as a TXT file for easy download.

'----------------------------------------------------------------------'' Name: PowerShell x64 Process Launcher' Designed specifically for use with' Tested Environment: Windows 2008 R2 SP1' Solarwinds Orion APM 4.0.2' Author: KMSigma on www.thwack.com;' Last Update: 2011-04-01''----------------------------------------------------------------------'' Parameters: (Ordered)' 1) File Path to PowerShell Script to Execute' * If the path includes spaces, surround the entire *' * parameter with double-quotes *' * eg. "C:\My Scripts\Script with spaces.ps1" *' 2) Second and Additional Parameters are those' which should be passed to the PowerShell Script' (Optional)''----------------------------------------------------------------------' Define a Debugging "flag" for error-trapping prior to executing' the PowerShell Script. Set to TRUE to write the execution' command to the APM Window, as the "message", but not execute' the PowerShell ScriptDim boolDebugboolDebug = true'Define a few variables firstDim strPowerShellExecutableDim strPowerShellScriptDim strPowerShellParameters' Check on the Number of Parameters - at least the path to the' PowerShell script needs to be defined.If Wscript.Arguments.Count = 0 Then ' Return the Error Message Wscript.echo "Message: Parameter 1 is missing, but required. " & _ "Re-execute with parameter defined as the full file path " & _ "to the PowerShell script to execute in 64-bit mode." ' Return the generic required "Statistic" value Wscript.echo "Statistic: 0" ' Return Quit with Error 1 - To Indicate Failure wscript.quit(1)Else ' Populate the variable to hold the PowerShell Script Path strPowerShellScript = Wscript.Arguments(0) ' Check to see if there are more arguments If ( wscript.arguments.Count >= 2 ) Then ' Cycle through the parameters passed to this vbScript and store in an array For i = 1 to Wscript.Arguments.Count - 1 ' "Paste" on each additional parameter strPowerShellParameters = strPowerShellParameters & " " & Wscript.Arguments(i) Next End IfEnd If' File Path to the PowerShell Executable' (This should NOT be modified for Windows 2008 R2)strPowerShellExecutable = "%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe"' Build the completed string for Shell ExecutionDim strPowerShellLaunchstrPowerShellLaunch = strPowerShellExecutable & " -file " & strPowerShellScript & strPowerShellParameters' Empty Variables to Free Memory' (probably unecessary, but good practice)Set strPowerShellExecutable = NothingSet strPowerShellScript = NothingSet strPowerShellParameters = NothingIf boolDebug Then ' ************************* ' *** Debugging Enabled *** ' ************************* ' Output what the script would run in the Message ' Output a statistic of zero ' Quit with an error (to encourage it to not be saved) wscript.echo("Message: PowerShell Launch Command: " & strPowerShellLaunch) wscript.echo("Statistic: 0") wscript.quit(1)Else ' ************************** ' *** Debugging Disabled *** ' ************************** ' Create new Shell Object Set objShell = CreateObject("Wscript.Shell") 'Assign the Shell Object to execute a powershell script with (optional) parameters from above Set objStdExec = objShell.Exec(strPowerShellLaunch) 'Close the Standard Input objStdExec.StdIn.Close() 'Read all the information from the standard output WScript.Echo(objStdExec.StdOut.ReadAll) 'exit using the same exit code as from powershell wscript.quit(objStdExec.ExitCode)End If