-1

I am trying to query virtual processor class(Win32_PerfRawData_HvStats_HyperVHypervisorVirtualProcessor) from a hyper-v server(windows 2012).

Used this to query from powershell-

gmic -namespace “root\virtualization” Win32_PerfRawData_HvStats_HyperVHypervisorVirtualProcessor | ElementName.

But getting the below error:

gwmi : Invalid namespace "root\virtualization"
At line:1 char:1
+ gwmi -namespace “root\virtualization” Win32_PerfRawData_HvStats_HyperVHypervisor ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [Get-WmiObject], ManagementException
    + FullyQualifiedErrorId : GetWMIManagementException,Microsoft.PowerShell.Commands.GetWmiObjectCommand

I have tried root\virtualization\v2 namespace as well, but same error.

After i tried steps from https://blogs.technet.microsoft.com/askperf/2014/08/08/wmi-repository-corruption-or-not/, figured out that, "virtualization" namespace does not exist in my server. I tried online to find mof file virtualization namespace,but couldn't find any result.

Please help!

Amit Shakya
  • 1,396
  • 12
  • 27
Venkat Teki
  • 2,233
  • 4
  • 21
  • 28

1 Answers1

0

root\virtualization and root\virtualization\v2 namespaces are present only on Hyper-v servers. You don't need any MOF here. Just connect to Hyper-V namespace and query.

I am guessing that you are trying queries from a machine which does not have Hyper-V.

$cred= Get-Credential  #Credential of Hyper-V server
Get-WmiObject -Namespace "root\virtualization" -Class Win32_PerfRawData_HvStats_HyperVHypervisorVirtualProcessor -ComputerName <Hyper-V server> -Credential $cred | Select ElementName

Updated

Run below mentioned powershell script to know Hyper-V server

 (get-item "HKLM:\SOFTWARE\Microsoft\Virtual Machine\Guest\Parameters").GetValue("HostName")
Amit Shakya
  • 1,396
  • 12
  • 27
  • No, i have a machine with hyper-v only. I ran this "SELECT * FROM Win32_ComputerSystem WHERE Model LIKE '%Virtual%'", and it returned me "Virtual Machine", which says , its hyper v. – Venkat Teki Jun 25 '16 at 02:37
  • This means your machine is "Virtual Machine" which is hosted on Hyper-V, it does not mean it is Hyper-V itself. – Amit Shakya Jun 25 '16 at 16:32
  • Running the above script (get-item*) returns me a machine name (xxx-hypv-test-01). As far as i know, this is a Windows 2012R2 VM running on Hyper-V. – Venkat Teki Jun 26 '16 at 12:53
  • That machine will have virtualization MOFs. You have to connect with respect to that machine. It means your current machine is hosted on xxx-hypv-test-01. Are your both machine same? – Amit Shakya Jun 26 '16 at 13:22
  • Yes, both are same. – Venkat Teki Jun 26 '16 at 13:42
  • I went to server manager dashboard the checked the features, as well. when i try to select "Hyper-v" feature from the feature set, getting a message saying, "hypervisor is already running" – Venkat Teki Jun 26 '16 at 13:44
  • Also, running "gcim Win32_ComputerSystem).HypervisorPresent" is returning True. PS C:\Windows\System32\wbem> (gcim Win32_ComputerSystem).HypervisorPresent True – Venkat Teki Jun 26 '16 at 13:48
  • Just to be clear, 1. Your hyper-v server is xxx-hypv-test-01 2. Machine you want to get information is xxx-hypv-test-01 – Amit Shakya Jun 27 '16 at 15:10
  • If Yes, i don't have a clue how are you missing MOFs, you can recreate your repository and try. Internally, Hyper-V also uses these MOFs. – Amit Shakya Jun 27 '16 at 15:13
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/115750/discussion-between-amit-shakya-and-venkataratnam). – Amit Shakya Jun 27 '16 at 16:01