WMI Connection to a Windows server on Azure

0

I am not able to make a WMI connection to any VM on Azure running windows OS. The same commands work perfectly well on my LAN and WAN to connect to any Windows machine.

For example

Get-WmiObject -Namespace "root\cimv2" -Class Win32_ComputerSystem -Impersonation 3 -ComputerName RemoteWinHost -Credential domain\username  

Works fine and gets me the desired info from "RemoteWinHost". However, the same fails when I try to get for a Azure VM and gives me this error :

Get-WmiObject : The RPC server is unavailable. (Exception from HRESULT: 0x800706BA)
At line:1 char:1
+ Get-WmiObject -Namespace "root\cimv2" -Class Win32_ComputerSystem -Im ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [Get-WmiObject], COMException
    + FullyQualifiedErrorId : GetWMICOMException,Microsoft.PowerShell.Commands.GetWmiObjectCommand

Can someone please guide me on how to accomplish the WMI connection to Azure VM. The VM is not a part of my domain and for Credential I am using the hostname in place of the domain name (hostname\username). Also tried it without appending the hostname. Same result.

powershell
azure
wmi
remote-access
asked on Stack Overflow Oct 9, 2017 by anil

1 Answer

0
  1. In most cases, it is the firewall. Check it and telnet the ports to make sure you can talk to them. I think the port should be TCP/UDP 135. You can try running the query from inside the target system to make sure of that.

  2. Another thing you can try is the Invoke-Command but it requires WinRM.

Invoke-Command -ScriptBlock {Get-WmiObject -Namespace "root\cimv2" -Class Win32_ComputerSystem} -Computer RemoteWinHost -Credential $credentialObject

  1. You can also check the DCOM objects on the target machine. It should be enabled. https://technet.microsoft.com/en-us/library/cc771387(v=ws.11).aspx
answered on Stack Overflow Oct 9, 2017 by Sid

User contributions licensed under CC BY-SA 3.0