Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
}
if($PSVersionTable.BuildVersion.Major -eq 10){
Write-Output "Note: Running on $($PSVersionTable.BuildVersion) and therefore we need to change back to Hyper-V module 2.0"
Write-Output "Unloading Hyper-V module 1.1 and loading Hyper-V module 2.0"
Remove-Module Hyper-V -Force
Import-Module Hyper-v
Get-Module -Name Hyper-V
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment