Cluster WMI query Test


Set-ExecutionPolicy unrestricted

cls

If(import-module failoverclusters)
{

Write-Host “Imported Cluster module”

}

Write-Host “Getting the cluster nodes…” -NoNewline
$nodes = Get-ClusterNode
Write-host “Found the below nodes ”
Write-host ” ”
$nodes
Write-host “”
Write-host “Running the WMI query….”
Write-host ” ”
ForEach ($Node in $nodes)
{
Write-Host -NoNewline $node

if($Node.State -eq “Down”)
{

Write-Host -ForegroundColor White ” : Node down skipping”
}

else
{

Try
{
#success

$result = (get-wmiobject -class “MSCluster_CLUSTER” -namespace “root\MSCluster” -authentication PacketPrivacy -computername $Node -erroraction stop).__SERVER
Write-host -ForegroundColor Green ” : WMI query succeeded ”
}
Catch
{

#Failure

Write-host -ForegroundColor Red -NoNewline ” : WMI Query failed ”
Write-host “//”$_.Exception.Message
}
}

}

# save as .ps1

Advertisements

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 )

Google+ photo

You are commenting using your Google+ 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 )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: