开发者

Find SCVMM Management Server within a VM Host/VM

Is it possible to locate a SCVMM Management server from within a Hyper-v host? Is this possible via powershell? I am trying to find which machine manages one 开发者_StackOverflow社区of my Hyper-v hosts. I've had no luck searching through registry/wmi. Any ideas?

Thanks in advance!


Not sure about powershell, but I just had to do this today.

1) looked up the port config for scvmm. So far, 5985 looks like the one: Link

2) On your host, run netstat -ano |find "5985"

3) That should return a list scvmm management servers connected.


As far as I know, no. What you could do is to query all of your SCVMM servers and see which happens to know the guest.

Load up the VMM module and connect to your VMM.

# VM name, might or might not be hostname
$guestToLook = "myLostVM"
# A list of all of your VMM servers
$VMMServers = @("vmmsrv01", "vmmsrv02", "vmmsrv03")
$VMMServers | % {
    # Connect to VMM server
    Get-VMMServer $_
    # Get a VM from the VMM host by guest name
    $vm = Get-VM -name $myLostVM
    # If VM object is returned, you got the VM from current VMM host.
    if($vm.Name -eq $myLostVM) { "{0} is managed by VMM host: {1}" -f $vm.Name, $_}
}


Here's a solution via PowerShell.

First we need the registry path on the host for SCVMM config values.

  1. $scvmmAgentKeys = 'HKLM:\SOFTWARE\Microsoft\Microsoft System Center Virtual Machine Manager Agent\Setup'

Now we grab the SCVMM agent port from the registry path.

  1. $wsManTcpPort = (Get-ItemProperty -Path $scvmmAgentKeys -Name WSManTcpPort).WSManTcpPort

Finally, collect the addresses which are listening on that port.

  1. $scvmmAddress = (Get-NetTCPConnection -LocalPort $wsManTcpPort).LocalAddress | Get-Unique | where { $_ -ne "::" }

Note that if anything else has a connection established on the same port (default port at time of writing is 5985) then $scvmmAddress will be an array including the addresses of those other established connections, which are not necessarily SCVMMs.


Fantastic . The only correction shall be

3. $scvmmAddress = (Get-NetTCPConnection -LocalPort $wsManTcpPort).**Remoteaddress** | Get-Unique | where { $_ -ne "::" }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜