John Howard - Senior Program Manager in the Hyper-V team at Microsoft

Senior Program Manager, Hyper-V team, Windows Core Operating System Division.

Hyper-V: Locate Hyper-V enabled servers in your domain

Hyper-V: Locate Hyper-V enabled servers in your domain

  • Comments 4
  • Likes

It seems an eternity ago (May 2007) that I put up a post describing how to determine which domain-joined servers are running Virtual Server in your domain(s). Well that same functionality is present in Hyper-V, only the SCP or "Service Connection Point" in Active Directory is different - "Microsoft Hyper-V".

Here's a sample VBScript code. Save the contents as "FindServers.vbs" (text file download) and run from an elevated command prompt "cscript FindServers.vbs".

On Error Resume Next
Const SCP = "Microsoft Hyper-V"
 
' Add as many lines as needed for the domains in your org. 
DoQuery "DC=YOURDOMAIN,DC=com", "YOURDOMAIN", SCP
 
Sub DoQuery(szDomainDN, szDomainShortName, szSCP)
 
    Set oConnection = CreateObject("ADODB.Connection")
    Set oCommand = CreateObject("ADODB.Command")
    oConnection.Provider = ("ADsDSOObject")
    oConnection.Open "Ads Provider"
    oCommand.ActiveConnection = oConnection
    oCommand.Properties("Page Size") = 99
    oCommand.Properties("Searchscope") = &H2 'ADS_SCOPE_SUBTREE
    oCommand.Properties("Chase Referrals") = &H60 
             'ADS_CHASE_REFERRALS_ALWAYS
    oCommand.CommandText = _
       "select distinguishedName from 'LDAP://" & _
       szDomainDN & "' " & _
       "where objectCategory='serviceConnectionPoint' " & _
       "and cn='" & szSCP & "'"
    Set oRecordSet = oCommand.Execute
    If Err Then
       wscript.echo _
           "ERROR: Unable to find Domain Rooted at: " & _
            szDomainDN
       exit sub
    End If
 
    If Not oRecordSet.EOF Then
       wscript.echo szDomainShortName & ":" & _
                    oRecordSet.RecordCount
 
       ' If you want to enumerate the machine names, 
       ' uncomment this block of code
       'oRecordSet.MoveFirst
       'Do Until oRecordSet.EOF
       '    szNodeName = _
       '      oRecordSet.Fields("distinguishedName")
       '    'Trim "CN=<szSCP>,CN="
       '    szNodeName = _
       '      mid(szNodeName, InStr(szNodeName,",CN=")+4) 
       '    'Trim the domain DN
       '    szNodeName = _
       '      Left(szNodeName,InStr(szNodeName,",")-1)
       '    wscript.echo szNodeName
       '    oRecordSet.MoveNext
       'Loop
    else
       wscript.echo szDomainShortName & ": 0"
    end if
 
    set oRecordSet = Nothing
    set oCommand = Nothing
    oConnection.Close
    set oConnection = Nothing
 
End Sub
       

To use the script, edit the call right at the top to "DoQuery", inserting the appropriate domain for your organisation. Add multiple lines if you have multiple domains. If you want a list of machine names, uncomment the code-block starting "oRecordSet.MoveFirst" and ending "Loop"

So I'm sure you're wondering, how many servers are actively running at Microsoft? With a bit of additional work using the script as the starting point, a simple database and some Excel macro wizardry, I happen to have been tracking the stats internally for some time now. While I can't share the scale, exact numbers and date-ranges for the graph below, you get an idea of the overall trend over a "few" months. (Don't worry about why there's two lines - the blue line is the important one). What I can say is that the current number is in the thousands. Many, many, thousands.

hypervusage

Cheers
John.

Comments
  • One of the advantages of having Virtualization integrated with Windows is that the Hyper-V (and in fact

  • Great post, explained really well and I could really understand. Thank you.

  • My hyper-v installation isn't registered as a service connection point....  Anyway to tell it to register itself?  I'm on a 2008 domain with hyper-v on a 2008 box.

  • David - when the VMMS service starts, it should register the SCP automatically. Are there any errors in the Hyper-V-VMMS event log channel?

    Thanks,

    John.

Your comment has been posted.   Close
Thank you, your comment requires moderation so it may take a while to appear.   Close
Leave a Comment