Posted by: Preetam | December 21, 2006

PowerShell-MSClustering

PowerShell -MSCluster-WMI
Word multithreading itself is obfuscating for me, and then think what programming can be for me. But powershell renews interest in me to become one, specially when .Net classes are invoked from here.

Simple example is here
$shell=new-object -com shell.application
$shell.ShutdownWindows()

And not that, there are so many other Methods available which can of great use, to find them all here…just type

$shell get-member

There was some problem in watching recording of web cast, so I decided to download only PPT’s, since I was hungry of codes and the latent thinking that generates in me out of the codes. I saw foreground and background impact. Instantly I thought hmmm looks different. And then mind starts to think….as it is mentioned in 8th Habit
No thing is as powerful as the idea whose time has come…..

Lots of jabbering lets get to the code.


Write-Host “CLUSTER VIEW ONLY IN THE ORDER OF DEPENDANCY” -backgroundcolor “GREEN” -FOREGROUNDCOLOR “BLACK”
WRITE-HOST ” ” -backgroundcolor “YELLOW”
WRITE-HOST “RESOURCE: QUROUM” -backgroundcolor “DARKRED”
Get-WmiObject -namespace root\mscluster -computername CLUSTERNAME -class mscluster_resource where{$_.type -eq “Physical Disk”} Select-Object Name,description,State
WRITE-HOST ” ” -backgroundcolor “GRAY”
WRITE-HOST “RESOURCE: NON SYSTEM DRIVES” -backgroundcolor “DARKRED”
Get-WmiObject -namespace root\mscluster -computername CLUSTERNAME -class mscluster_resource where{$_.type -eq “Volume Manager Disk Group”}
WRITE-HOST ” ” -backgroundcolor “GRAY”
WRITE-HOST “RESOURCE: IP ADDRESS” -backgroundcolor “DARKRED”
Get-WmiObject -namespace root\mscluster -computername CLUSTERNAME -class mscluster_resource where{$_.type -eq “IP address”}
WRITE-HOST ” ” -backgroundcolor “GRAY”
WRITE-HOST “RESOURCE: NETWORK NAME” -backgroundcolor “DARKRED”
Get-WmiObject -namespace root\mscluster -computername CLUSTERNAME -class mscluster_resource where{$_.type -eq “Network Name”}
WRITE-HOST ” ” -backgroundcolor “GRAY”
WRITE-HOST “RESOURCE: FILE SHARE” -backgroundcolor “DARKRED”
Get-WmiObject -namespace root\mscluster -computername CLUSTERNAME -class mscluster_resource where{$_.type -eq “File Share”}


Code is very simple but results you get out of it are truly superb. Formatting makes life easier and interesting.I thought of using WMI/Clustering to get the results.

Lets get to first line
WRITE-HOST “RESOURCE: QUROUM” -backgroundcolor “DARKRED”
Get-WmiObject -namespace root\mscluster -computername CLUSTERNAME -class mscluster_resource where{$_.type -eq “Physical Disk”} Select-Object Name,description,State

My intention here is to sort cluster resource by type. In other words you puch below line on CMD prompt.

Cluster /cluster:CLUSTERNAME RESOURCE

And you would get cluster resources. I sorted these resources by type. Common types are file share,Network Name,Physical disk and third party would like Volume Manager Disk Group. In order to get cluster WMI you have to specifically connect to it. You simply can’t do get-wmiobject win32_Service.

Once that happen, next code is…

Write-host “ “ –foregroundcolor “DARKRED”

Above line, I have put lots of spaces to get you DARKRED thik border.

Not much…

I can’t get you the output of it, or screen shot, But you won’t be feeling sorry if run similiar in any MSCluster enviornment.


Responses

  1. a bit late, but you might like this :

    http://mow001.blogspot.com/2005/12/msh-cluster-watcher-script.html

    Greetings /\/\o\/\/


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Categories

%d bloggers like this: