PowerTip: Identify Locations of Hyper-V Config Files

PowerTip: Identify Locations of Hyper-V Config Files

  • Comments 4
  • Likes

Summary: Use PowerShell to find the .xml files of Hyper-V virtual machines.

Hey, Scripting Guy! Question How can I use Windows PowerShell to easily find the location of my virtual machines after I reinstalled Hyper-V in Windows Server 2008 R2?

Hey, Scripting Guy! Answer The virtual machine configuration is stored in an .xml file with a GUID, and you can use Get-ChildItem to easily parse a hard drive to find the location.

To scan drive C: for all .xml files:

GET-CHILDITEM C:\ -recurse -include *.xml

To be more efficient, target only C:\ProgramData where the data, including hidden folders, is stored:

GET-CHILDITEM C:\ProgramData –recurse –include *.xml –force

If you need to manually rebuild configuration data, you can parse files for machine names and data.

Your comment has been posted.   Close
Thank you, your comment requires moderation so it may take a while to appear.   Close
Leave a Comment
  • Ttoal XML files in C:\progrmdata  Count    : 2753

  • @jrv

    Good point.   To second part is to identify content which oddly enough I didn't type in

  • The files are kept in the Hyper-V folder:

    C:\ProgramData\Microsoft\Windows\Hyper-V\Virtual Machines

    Each VM is an XML file named with a GUID.  They should be the only XML files in that folder.  The folder can be moved but usually isn't as the XML file can relocate the VM to anywhere.   All VM info for settings shown in Hyper-V Manager should be in these files.

  • I have been trying to solve this for days. all i needed was a comma and some regex

    gci C:\ -r -in *.xml |  | ?{$_.name -match "\w{7,}-\w{3,}-\w{3,}-\w{3,}-\w{11,}"}

    gci C:\ProgramData –r -in *.xml |  | ?{$_.name -match "\w{7,}-\w{3,}-\w{3,}-\w{3,}-\w{11,}"}