Tuesday, July 24, 2012

PowerShell Modules & Parameters

Last week I created an advanced Management Pack for a customer to monitor their VMware environment [1]. To achieve their needs the VMware admin created the PowerCLI (PowerShell with VMware Snap Ins) scripts and provided them to me. My part of the task was to implement the scripts into SCOM PowerShell workflows.

There is a real good guide for creating a PowerShell workflow by our friend Stefan Koell so it is not necessary to invent the wheel again. You’ll find all parts of the blog here, here, here and here.

So I created the MP and imported it into my MG but unfortunately it did not run as expected. After some troubleshooting (that was hard, even in the traces I was not able to find the issue) I found out that the parameters from the MP itself were not given to the scripts.

After reviewing the scripts I realized that there was a very simple part missing: The script author used $args variable instead of declaring the parameters.

So after declaring them by adding


and replacing the $args[…] by the variables declared before everything worked as expected.

That was easy but still tricky to troubleshoot…

[1] There are 3rd Party solutions from our partners available. You’ll find them here.

All information is provided "as is" without any warranty! Try in lab before. Handle with care in production.

1 comment:

  1. This blog site is highly very good and enlightening. I'll post a link to this page on my website. I'm sure my site visitors will discover that particularly useful!