Skip to content

Instantly share code, notes, and snippets.

@DeploymentBunny
Created December 17, 2015 11:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DeploymentBunny/29e88f85cbb5f78b04b6 to your computer and use it in GitHub Desktop.
Save DeploymentBunny/29e88f85cbb5f78b04b6 to your computer and use it in GitHub Desktop.
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