PowerShell Hyper-V Configuration Backup report

In preparing my home lab to upgrade to Windows 10 (I’ll be leaving server 2012 R2 w/ Desktop experience behind, after years as my daily driver).

I realized that I’d essentially need to rebuild my Hyper-V setup (which really isn’t so bad, just reimporting my VM .xml files and then setting the VHDs the right way again) when I got to Windows 10, so I wanted a quick reference of which VM files were where and how my switches were laid out.

This is what I came up with!

It gives us first the configuration of all of our switches, whether they’re bound to a physical adapter and whether the management OS shares the NIC, if so. It then breaks down by VM, where the .xml file lives for it, which drives it has mounted, which NICs, whether Dynamic RAM is turned on and finally the startup memory.

Pretty much everything you’ll need to know when rebuilding VMs and you still have access to the source files!

This depends on the .css source file found here in my DropBox, to give us pretty colors :)

$Switches = Get-VMSwitch | Select Name,SwitchType,AllowManagementOS,NetAdapterInterfaceDescription

$VMs = get-vm | % {
       $VMXML = gci $_.Path -Recurse -Include *xml | ? baseName -like "$($_.VMId)*"
       $VMDisk = Get-VMHardDiskDrive -VMName $_.Name | Select -expand Path 
       $VMNics = Get-VMNetworkAdapter -VMName $_.Name | select -expand SwitchName
            Drives = $VMDisk -join "`n"
            NICs = $VMNics -join ";"
            DynamicMemory = $_.DynamicMemoryEnabled;
            StartupMemory = $_.MemoryStartup/1mb
       } | ConvertTo-Html -Fragment

$base = $switches

$companyLogo = '<div align=left><img src="C:\Users\Stephen\Dropbox\Speaking\Demos\logo.png"></div>'
$header = @"
 <h1>Hyper-V Configuration Report</h1>
 <p>The following report was generated at $(Get-Date) and contains the needed information to recreate the Hyper-V environment which existed before on $($Env:Computername)

 <h3>Switch Configuration</h3>

$post = @"
<h3>VM Configuration</h3>

 <h3>These VMs were found on the L: and V: drives</h3>

$HTMLbase = $base | ConvertTo-Html -Head $header -CssUri "C:\Users\Stephen\Dropbox\Speaking\Demos\style.css" `
                            -Title ("VM Configuration Report for $((Get-Date -UFormat "%Y-%m-%d"))") `
                            -PostContent $post
$HTMLbase | out-file l:\VMBackup_$((Get-Date -UFormat "%Y-%m-%d"))_Log.html 

Upcoming Events: PowerShell Training, by me!

If you’ve been following my blog, chances are that you enjoy PowerShell, and hopefully like my take on presenting information and the like! I’m happy to announce that we’ve got open registration now for two exciting upcoming PowerShell training events!

The South-Eastern PowerShell Bootcamp Tour


This is THE premier hands-on PowerShell Bootcamp event.   Come with no command line, DOS, VBScripting or other experience and leave writing powerful one-liners and scripts.  You’ll receive poignant tips from the field in a custom course designed and taught by Microsoft MVP of Scripting, Stephen Owen.  Bring your laptop and appetite, as Breakfast and Lunch are included!


Continue reading

Check your US Postal Service Package Status with PowerShell!

Hey guys!

Been a while since I wrote up a fun little PowerShell REST API tool, so here we go! I taught a four day PowerShell boot camp for a Fortune 50 company, and during the event, one of my students called out the need to track his package delivery online.

The discussion quickly turned high-dork, as we dug in to see if there was a convenient way to get this information.

It turns out that the United States Postal Service has a REST API we can use to check for the status of package delivery.

Continue reading

Part IV – DSC – One-Click Domain Controller


This post is part of the Learning PowerShell DSC Series, here on FoxDeploy. Click the banner to return to the series jump page!

Hey guys, I haven’t forgotten about you, but it’s been a very busy month here, with me traveling to Redmond ( Microsoft HQ! I have to post a pic!) for some exciting Microsoft meetings and then back and forth to Minneapolis for a new client!

2015-06-02 13.48.56

I didn’t know what to do with my hands in this picture.

I’ve been receiving your messages and have now released the final step in this one-click Domain controller DSC Build. To recap, we left off with a DSC Config that would make our machine a domain controller, but that was it. Continue reading

Part III – Using Advanced GUI Elements in PowerShell


This post is part of the Learning GUI Toolmaking Series, here on FoxDeploy. Click the banner to return to the series jump page!

Welcome back to the GUI Series here on FoxDeploy.com! In the previous weeks, I’ve had a lot of feedback and requests from you guys (which I absolutely love! Assuming I don’t need sleep, I’m content to stay up till the wee hours of the morning helping you guys out and responding to your comments or requests, so keep ’em coming!). As for where this blog is heading…I’ve really been bit hard by the maker bug, and I recently purchased a RaspBerry Pi 2, which is super awesome and incredibly powerful. Direct deploying a program from Visual Studio to this little guy and seeing it light up and project content to my HDMI monitor really makes it feel like I’m doing something tangible. I’ll be making a whole series of posts about cool things you can do with the Pi. If you have any ideas, send ’em over!

We’re going to cover a number of topics in this one, namely ‘how do I do ex’ questions. We’ll have two somewhat silly examples to start, followed by an actually useful GUI to create a user to wrap us up here.

We’ll specifically be hitting all of these guys here, in order.

• Hide a UI Element (by special request)
• Use Checkboxes
• Use radio buttons (by special request)
• Populate a drop-down box automatically

Also, in a big departure from the past, I’ll not be posting full code on here anymore. From now on, code samples from here will always be linked and kept up-to-date on GitHub. You can find the code from this post here: https://github.com/1RedOne/Post_III

Alright, let’s get started. Power up Visual Studio and create a new project, specify ‘WPF’ as your type in the search box.
Continue reading