Tag Archives: PowerShell

Reading out PS NoteProperty’s

6 Nov

 

Case:

How do i read out the IsManagementServer property on the example below ??

$X= Get-SCOMClass -Name “Microsoft.SystemCenter.ManagementServer” | Get-SCOMMonitoringObject

The output is:

[Microsoft.SystemCenter.HealthService].AuthenticationName : SRV.stateview.nl

[Microsoft.SystemCenter.HealthService].MaximumQueueSize : 104857600

[Microsoft.SystemCenter.HealthService].MaximumSizeOfAllTransferredFiles : (null)

[Microsoft.SystemCenter.HealthService].RequestCompression : True

[Microsoft.SystemCenter.HealthService].CreateListener : True

[Microsoft.SystemCenter.HealthService].Port : 5723

[Microsoft.SystemCenter.HealthService].IsRHS : True

[Microsoft.SystemCenter.HealthService].IsManagementServer : True

 

Now I want to get the IsManagementServer value

$.[Microsoft.SystemCenter.HealthService].IsManagementServer

But it Fails

$.IsManagementServer

But it Fails

How do I read it out ??

Solution:

Running the command below..

$x | GM

pointed out it was a noteproperty

image  

So since its using [] i have to use ” to make a string of it

So the correct syntax would be

$x.'[Microsoft.SystemCenter.HealthService].IsManagementServer’.value

Happy Scomming

Michel Kamp

Advertisements

Orchestrator and PowerShell Actions returned from a marriage therapy session…

11 May

 

Yes I know I blog a lot on SCOM related posts but this don’t imply that I don’t use the other system center products. As you know or not know that I work for a company that hosts SCOM as private clouds. So I use also a lot of Orchestrator runbooks to automate the boring and complex hand work and to glue all the components together.

The problem

As one of my best practice rules I try to use only the out of the box delivered actions (IPs). Some times I can’t find the correct action and have to use PowerShell to get it working. So I use the Run Dot Net Script PowerShell action. And now the bad marriage starts. You all know when you try to type the PowerShell code into the action window you get very strange line breaks and you completely miss the code IntelliSense and error/debug features that you will have in power shells ISE or other PowerShell editors. So what do you do ?

(1) Open the PowerShell editor lets say ISE and program your script.

(2) After testing you SAVE IT TO YOUR SOURCE SAFE solution. for example TFS

(3) Now you copy and paste your PowerShell code from the ISE editor to the orchestrator PowerShell action.

(4) you replace the the input parameters with the correct orchestrator subscriptions.

(5) you check-in the runbook.

So far so good… but .. Now you have detected a bug in your PowerShell action (and I think I am not the only one that has bugs in his work) . You will have to do the reverse actions and repeat the steps in forward order again. Pffff very time consuming…

The solution

After some thinking I came with a solution. I have made a PowerShell ISE plugin that does the following.

(1) connects to the Orchestrator database . You must supply the connection settings in the Config tab first.

(2) You Press on LOAD and it shows you a list of PowerShell actions you have in your workbook(s)

(3) You select the correct PS action by double click on it.

(4) the PowerShell code from that action will be opened in the ISE editor.

(5) the subscription parameters are collected also and a extra PowerShell code is created for you to fill in the parameters with values for off site testing. *Planned for next release.

(6) you bug fix and test the script.

(7) you press in the ISE orchestrator plugin on Save and the script will be saved to the orchestrator workbook action. (be sure that it is checked out , save will work but’s better to do so)

Now you will have the workbook action with the fixed script. You even don’t have to worry about the parameter subscriptions because the are all there… Press refresh in the Orchestrator designer and look at the properties again to check it out.

SNAGHTML5ea57926

Cool isn’t it !!

And that’s why I also share it with the community !

See download link below:

https://skydrive.live.com/redir?resid=2FFA0FC5B0B89EED!1391&authkey=!AGXGNQLdATUuMDg

1) unzip the file and read the readme.txt file for setup instructions.

2) go to the config tab and specify the correct SQL and DB. Remember its using integrated security.

Next release is coming soon. This version will also have a feature that replaces all the Orchestrator parameter subscriptions with real values from a runbook run history. So you can debug with real parameter values. I had some troubles making it stable so its coming later on…

Happy SCOMMING … Orchestrating.  

Michel Kamp