Archive | January, 2011

Testing a SCOM PowerShell script from the command line

When I wrote SCOM VBScripts in the past, it was easy to test the script and see if I was getting the right output. 

I would simply run the cscript command from the command prompt to get the output.

C:\temp2\cscript count.vbs "c:\temp2" 4

 vbscript4

But now with a similar SCOM PowerShell script I get useless output.

PS C:\temp2\ .\filecount.ps1 -Folder ‘C:\temp2’ -FCount 5

pshell

To fix this I have to add a simple line of code to the end of my PowerShell script

$api.Return($bag)

 

Now I can see the same output that my VBScripts gave me in the past.

powershell2

Don’t forget to comment the line out after you are done testing.

powershell3

Continue Reading