none
Powershell Get-VMHost to retrieve default Hyper-V save location RRS feed

  • Question

  • Hi all,

    I hope I'm on the right forums, this is my first time posting on technet. Is there a way in Powershell to read from a Hyper-v host the default save location for virtual machines? I know you can change the save location with the Set-VMHost cmdlet, but it looks like Get-VMHost doesn't quite work the same way.

    I know the default location with Hyper-V is under C:\Hyper-V Virtual Machines\ but for part of a script I'm writing to deploy new virtual machines to a server, it should be able to connect to the Hyper-V host and intelligently decide where to make the new VM at. I do not want to assume that servers are using the default location, or to start changing the location on existing servers.

    Wednesday, June 19, 2019 10:21 PM

Answers

  • Hello Marcus,

    You can use: Get-VMHost | fl *

    This displays the extended information and you are probably looking for the VirtualMachinePath.

    "Get-VMHost | Select-Object VirtualMachinePath" can also be used

    • Proposed as answer by Malcolm Kobes Wednesday, June 19, 2019 10:31 PM
    • Marked as answer by Marcus Dean Wednesday, June 19, 2019 10:34 PM
    Wednesday, June 19, 2019 10:31 PM

All replies

  • Hello Marcus,

    You can use: Get-VMHost | fl *

    This displays the extended information and you are probably looking for the VirtualMachinePath.

    "Get-VMHost | Select-Object VirtualMachinePath" can also be used

    • Proposed as answer by Malcolm Kobes Wednesday, June 19, 2019 10:31 PM
    • Marked as answer by Marcus Dean Wednesday, June 19, 2019 10:34 PM
    Wednesday, June 19, 2019 10:31 PM
  • Awesome, thank you! I hoped it would be simple.
    Wednesday, June 19, 2019 10:34 PM
  • Hello Marcus,

    You can use the Set-VMHost PowerShell cmdlet to change the default Hyper-V virtual machines folder path.

    Example 1:

    Set-VMHost -VirtualMachinePath "Full path of folder"

    (Current Hyper-V host)


    Example 2:

    Set-VMHost -ComputerName "Hyper-V host name" -VirtualMachinePath "Full path of folder"
    (Specific Hyper-V host)


    Best regards,
    Leon


    Blog: https://thesystemcenterblog.com LinkedIn:

    Wednesday, June 19, 2019 10:35 PM