Press "Enter" to skip to content

Switch between Hyper-V & VMware CMDlets on the same system

Reading Time: < 1 minute

Original script found on

Had to modify it to make it work, because Add-PSSnapin no longer works with VMWare

Function Add-VMCs($Default) {
    If ($Default -eq 'h' -or $Default -eq 'v') {
        Remove-Module -Name Hyper-V -ErrorAction SilentlyContinue
        Get-Module -Name VMware* | Remove-Module -Force -ErrorAction SilentlyContinue
                If ($Default -eq 'h') {
            $null = Get-Module -ListAvailable VMware* | Import-Module -ErrorAction SilentlyContinue
            Import-Module -Name Hyper-V
        } ElseIf ($Default -eq 'v') {
            Import-Module -Name Hyper-V
            $null = Get-Module -ListAvailable VMware* | Import-Module -ErrorAction SilentlyContinue --no-verbose
    } Else {
        Write-Output -Verbose "INFO: No changes made`r`nUse H to set Hyper-V as the default (Add-VMCs H) or use V to set VMware as the default (Add-VMCs V)."


Add-VMCs V will switch to using VMware CMDlets and Add-VMCs H will switch to Hyper-V cmdlets

Share & contribute
Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.