Powershell Resize-VHD is not recognized as the name of a cmdlet

powershellvhd

I'm trying to use Resize-VHD cmdlet, but this results in the following error:

PS> Resize-VHD -Path "C:\Container.vhd" -SizeBytes 20GB
    Error:
        Resize-VHD : The term 'Resize-VHD' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
        At line:1 char:1
        + Resize-VHD -Path "C:\Container.vhd" -SizeBytes 20GB
        + ~~~~~~~~~~
            + CategoryInfo          : ObjectNotFound: (Resize-VHD:String) [], CommandNotFoundException
            + FullyQualifiedErrorId : CommandNotFoundException

How do I fix that?

Best Answer

  • Turns out I needed to install Hyper-V features on Windows (even though I don't need Hyper-V itself, I use VHD as portable file container)

    1. Go to Control Panel | Programs and features | Turn windows features on or off
    2. Tick Hyper-V | Hyper-V Management tools | Hyper-V Module for Windows PowerShell
    3. When installed, reboot if asked
  • Related Question