Skip to content

Instantly share code, notes, and snippets.

@DeploymentBunny
DeploymentBunny / gist:29e88f85cbb5f78b04b6
Created December 17, 2015 11:56
Chnage PowerShell Module
# Check Build Version
# Due to a minor bug in the Hyper-V module 2.0 we need to replace that with the old version when creating VM's that uses Add-VMDvdDrive
if($PSVersionTable.BuildVersion.Major -eq 10){
Write-Output "Note: Running on $($PSVersionTable.BuildVersion) and therefore we need to change to Hyper-V module 1.1"
Write-Output "Unloading Hyper-V module 2.0 and loading Hyper-V module 1.1"
Remove-Module Hyper-V -Force
Import-Module Hyper-v -RequiredVersion 1.1 -Force
Get-Module -Name Hyper-V
}