I wanted to monitor the get-vm module via powershell script, but the problem is that this module is not suitable for 2008 R2 ( https://docs.microsoft.com/en-us/previous-versions/windows/it-pro/windows-server -2012-R2-and-2012 / hh846767 (v = ws.11) ) How to be ?? Are there alternatives?

Script ( https://github.com/ameiji/Zabbix-HyperV-Templates )

  • What is your powershell version? - Viktor Tomilov
  • what does not mean? complete the question with details - Senior Pomidor
  • Ps exactly how do admin run? - Senior Pomidor
  • What is your powershell version? - Viktor Tomilov was 2, put the 3rd version. - Aba
  • Yes, I run on behalf of the Administrator. I wrote on the microsoft site that the get-vm module is supported only in windows server 2012. Can I confuse something!? - Aba

1 answer 1

Full WMI support for Hyper-V appeared only starting from Server 2012. I don’t have 2008 R2 now, so I can’t check it, but as far as I remember, with the upgrade to version 3, Powershell was able to monitor Hyper-V, however, there were problems with rights (for which you need to run under the admin).

If in any way, you can go another way: put the PowerShell Management Library for Hyper-V . Put simply, working with her is also easy. Here is a list of the most useful features:

ΠŸΠΎΠ΄ΠΊΠ»ΡŽΡ‡Π΅Π½ΠΈΠ΅ ΠΊ Π²ΠΈΡ€Ρ‚ΡƒΠ°Π»ΡŒΠ½ΠΎΠΉ машинС New-VMConnectSession ΠœΠ°Π½ΠΈΠΏΡƒΠ»ΠΈΡ€ΠΎΠ²Π°Π½ΠΈΠ΅ состояниСм Π²ΠΈΡ€Ρ‚ΡƒΠ°Π»ΡŒΠ½Ρ‹Ρ… машин Get-VMState, Set-VMState, Convert-VmState, Ping-VM, Test-VMHeartBeat, Shutdown-VM, Start-VM, Stop-VM, Suspend-VM Get-VMKVP, Add-KVP, Remove-KVP, Get-VMJPEG Π’ΠΎΠ·ΠΌΠΎΠΆΠ½ΠΎΡΡ‚ΡŒ Π΄Π΅Π»Π°Ρ‚ΡŒ бэкапы, экспорт Π²ΠΈΡ€Ρ‚ΡƒΠ°Π»ΡŒΠ½Ρ‹Ρ… машин ΠΈ снятиС ΡΠ½ΡΠΏΡˆΠΎΡ‚ΠΎΠ² Export-VM, Import-VM, Get-VMSnapshot, Choose-VMSnapshot, Apply-VMSnapshot, New-VMSnapshot ,Remove-VMSnapshot, Rename-VMSnapShot, Update-VMSnapshot, Get-VMSnapshotTree, Get-VmBackupScript Π”ΠΎΠ±Π°Π²Π»Π΅Π½ΠΈΠ΅ ΠΈ ΡƒΠ΄Π°Π»Π΅Π½ΠΈΠ΅ Π²ΠΈΡ€Ρ‚. машин, настройка ΠΈΡ… свойств New-VM, Remove-VM, Set-VM, Get-VMCPUCount, Set-VMCPUCount, Get-VMMemory, Set-VMMemory, Set-VMSerialPort Π£ΠΏΡ€Π°Π²Π»Π΅Π½ΠΈΠ΅ дисковыми ΠΊΠΎΠ½Ρ‚Ρ€ΠΎΠ»Π»Π΅Ρ€Π°ΠΌΠΈ Get-VMDiskController Add-VMSCSIController, Remove-VMSCSIcontroller Get-VMDriveByController, Add-VMDRIVE, Remove-VMdrive Get-VMDiskByDrive, Add-VMDISK, Set-VMDisk, Get-VMDisk Get-VMFloppyDisk, Add-VMFloppyDisk Add-VMNewHardDisk Π£ΠΏΡ€Π°Π²Π»Π΅Π½ΠΈΠ΅ сСтСвыми интСрфСйсами Get-VMNic, List-VMNic, Choose-VMNIC, Add-VMNIC, Remove-VMNIC, Set-VMNICAddress, Set-VMNICConnection, Get-VMNicport, Get-VMnicSwitch, Choose-VMSwitch, New-VMSwitchPort, Get-VMByMACaddress, Choose-VMExternalEthernet, New-VMExternalSwitch, New-VMInternalSwitch,New-VmPrivateSwitch Π Π°Π±ΠΎΡ‚Π° с VHD Ρ„Π°ΠΉΠ»Π°ΠΌΠΈ Get-VHDDefaultPath, Get-VHDInfo, New-VHD, Compact-VHD, Test-VHD,Convert-VHD,Merge-VHD,Mount-VHD, Unmount-VHD 
  • For Server-2012, does it make sense to install this library or can you get by with system classes? - Alexey Kozlov
  • @AlexeyKozlov at your discretion. It was slightly extended compared to the standard, but MS could have changed something already, I hadn’t moderated Hyper-V for a long time. - Viktor Tomilov