One of the big challenges as we get close to shipping Windows HPC Server is closing the door on product changes. Now that we have a lot of internal and external customers using the product, everybody generates lots of great ideas on how to improve it. We call these DCRs (Design Change Request) and we spend a lot of time arguing over whether we should accept them (creating additional design, programming, test, documentation, and localization work) or reject them (shipping a product which might suffer from anything between small annoyances and large deployment blockers or support issues) As we get closer and closer to RTM, the bar for accepting DCRs gets higher. This is the story of one DCR we rejected.

A developer on my team filed a DCR asking for a Powershell cmdlet that returned a list of all the HPC clusters in the domain. This would be handy for a lot of different reasons. We debated this a bit and eventually rejected it because it’s not really specific to the HPC product and because you can already do this pretty easily in Powershell. Powershell doesn’t have built-in support for ActiveDirectory, but you can call out to the .NET Framework and use the DirectorySearcher class.

PS C:\> $Searcher = New-Object DirectoryServices.DirectorySearcher

PS C:\> $Searcher.Filter = "(&(serviceClassName=MicrosoftComputeCluster)(keywords=Version2))"

PS C:\> $Searcher.FindAll()

Path                                    Properties

----                                    ----------

LDAP://CN=MicrosoftComputeCluster,CN... {keywords, servicednsname, servicedn...

LDAP://CN=MicrosoftComputeCluster,CN... {keywords, servicednsname, servicedn...

LDAP://CN=MicrosoftComputeCluster,CN... {keywords, servicednsname, servicedn...

LDAP://CN=MicrosoftComputeCluster,CN... {keywords, servicednsname, servicedn...

LDAP://CN=MicrosoftComputeCluster,CN... {keywords, servicednsname, servicedn...

LDAP://CN=MicrosoftComputeCluster,CN... {keywords, servicednsname, servicedn...

LDAP://CN=MicrosoftComputeCluster,CN... {keywords, servicednsname, servicedn...

 

What you get back from $Searcher.FindAll() is a list of all the computer objects in the domain where the HPC job scheduler is running. Really all you care about here is the servicednsname property, so we can use ForEach-Object (abbreviated as foreach or %) to filter out the other stuff.

PS C:\> $schedlist = $Searcher.FindAll() | foreach {$_.Properties.servicednsname}

PS C:\> $schedlist

kyril.ntdev.corp.microsoft.com

37-4611A2803A.ntdev.corp.microsoft.com

JVERT.ntdev.corp.microsoft.com

GRET57001.ntdev.corp.microsoft.com

R25-1183D1023.ntdev.corp.microsoft.com

gret10.ntdev.corp.microsoft.com

liwei.ntdev.corp.microsoft.com

 

Now we have a list of all the HPC schedulers in the domain, we can stuff that into the Get-HpcClusterOverview cmdlet and collect their individual states:

PS C:\> $overview = $schedlist | foreach {get-hpcclusteroverview -scheduler $_}

 

If there are a lot of clusters in your domain that are unreachable, this might take a while because Get-HpcClusterOverview will wait for each connection to time-out. Once it does complete, $overview will have a list containing a snapshot of the statistics for each active cluster. You can pipe that through format-table or do whatever you like with it.

PS C:\> $overview | format-table

 

Cluster Version TotalNo ReadyNo Offline Drainin Unreach TotalCo BusyCor IdleCor

Name            deCount deCount NodeCou gNodeCo ableNod reCount  eCount  eCount

                                     nt     unt  eCount

------- ------- ------- ------- ------- ------- ------- ------- ------- -------

kyrilfl 2.0....       1       1       0       0       0       2       0       2

37-4... 2.0....       4       4       0       0       0      32       0      32

JVERT2  2.0....       1       1       0       0       0       2       0       2

GRET... 2.0....       1       0       1       0       0       8       0       0

R25-... 2.0....       3       3       0       0       0      20       0      20

gret10. 2.0....       1       0       1       0       0       8       0       0

liwei.. 2.0....       1       1       0       0       0       2       0       2

 

I think this is a great example of how to use Powershell to easily glue together two different systems (AD and HPC) in an interactive way. I hope this will give you a little taste of some of the neat things you can do with the Powershell support in HPC as well as a little taste of what the end-game of shipping a product at Microsoft involves.

John Vert

Development Manager

High Performance Computing