ananace / fog-hyperv

Hyper-V provider for fog
MIT License
8 stars 1 forks source link

Detect Hyper-V version for using newer cmdlets #8

Closed ananace closed 7 years ago

ananace commented 7 years ago

Some cmdlets (*-VMGroup, *-VMHostCluster, etc) are only available on new enough versions of Hyper-V.
This should be detected so such actions can be handled intelligently.

Vagrant's method of doing this;

$VmmsPath = if ([environment]::Is64BitProcess) { "$($env:SystemRoot)\System32\vmms.exe" } else { "$($env:SystemRoot)\Sysnative\vmms.exe" }
$HyperVVersion = [version](Get-Item $VmmsPath).VersionInfo.ProductVersion
ananace commented 7 years ago

Worth noting is that this should probably be done in a manner that only cares about the directly accessed machine, since that one is the one that will actually be executing cmdlets.