TEE14 Scripted Demo 2 – Live Exporting & Cloning Hyper-V Virtual Machines

The second demo in my presentation focused on being able to export running virtual machines. We can also export a checkpoint to create a merged export. And then we can import a VM to clone it, maybe for troubleshooting, diagnostics, performance testing, upgrade testing, and rollback testing …. all on a “production” VM with “production” data and services.

This script will do:

  1. Clean up the lab
  2. Show the running VM
  3. Export the VM
  4. Show the export
  5. Remove the export
  6. Checkpoint the VM
  7. Export the checkpoint
  8. Import the checkpoint to create a new VM
  9. Highlight the new VM is running alongside the old VM

CLS
$DemoVM1 = “NUMA”
$ExportPath = “D:\Exports\”
$ImportedVMName = “Newly Imported VM”
$ImportVMPath = “D:\Virtual Machines\$ImportedVMName”

#Clean up the demo
Start-VM $DemoVM1 | Out-Null
CLS
If (Test-Path $ExportPath)
{
Remove-Item $ExportPath -Recurse -Force | Out-Null
}
Remove-VMSnapshot $DemoVM1 -ErrorAction Ignore | Out-Null
Stop-VM $ImportedVMName -Force -ErrorAction Ignore | Out-Null
Remove-VM $ImportedVMName -Force -ErrorAction Ignore | Out-Null
Remove-Item $ImportVMPath -Recurse -Confirm:$false -ErrorAction Ignore | Out-Null

#Start the demo
Read-Host “Start the demo”
Write-Host “`nThis is the virtual machine $DemoVM that we will be working with” -foregroundcolor red -backgroundcolor yellow
Get-VM $DemoVM1 | Select Name, Status | Out-Host

#Export the VM
Read-Host “`nExport the running VM”
Write-Host “`nCreating an export of the virtual machine $DemoVM while it is running” -foregroundcolor red -backgroundcolor yellow
Write-Host “`nExport-VM $DemoVM1 -Path $ExportPath”
Export-VM $DemoVM1 -Path $ExportPath | Out-Host
Write-Host “`nHere is the export of the still running virtual machine” -foregroundcolor red -backgroundcolor yellow
Dir $ExportPath\NUMA

#Create a VM checkpoint
Read-Host “`nCreate a checkpoint of the VM $DemoVM1”
Write-Host “`nCreating a checkpoint (formerly known as a snapshot) of the virtual machine $DemoVM1” -foregroundcolor red -backgroundcolor yellow
Write-Host “`nCheckpoint-VM $DemoVM1 -SnapshotName `”Demo Checkpoint AKA Snapshot`””
Checkpoint-VM $DemoVM1 -SnapshotName “Demo Checkpoint AKA Snapshot”
Write-Host “`nThis is the new checkpoint” -foregroundcolor red -backgroundcolor yellow
Get-VMSnapshot $DemoVM1 | Out-Host

 

#Export the VM checkpoint
Read-Host “`nDo an export of the VM $DemoVM1 checkpoint”
If (Test-Path $ExportPath)
{
Remove-Item $ExportPath -Recurse -Force | Out-Null
}
Write-Host “`nWe can export a checkpoint of a running virtual machine” -foregroundcolor red -backgroundcolor yellow

Write-Host “`nNew-Item -ItemType Directory $ExportPath\$DemoVM1”
New-Item -ItemType Directory $ExportPath\$DemoVM1

Write-Host “`nExport-VMSnapshot -Name “Demo Checkpoint AKA Snapshot” -VMName $DemoVM1 -Path $ExportPath”
Export-VMSnapshot -Name “Demo Checkpoint AKA Snapshot” -VMName $DemoVM1 -Path $ExportPath | Out-Host

Write-Host “`nHere is the export” -foregroundcolor red -backgroundcolor yellow
Dir $ExportPath\NUMA

#Import the VM checkpoint to create a new VM
Read-Host “`nImport the exported checkpoint to create a new VM”
Write-Host “`nNow we will create a whole new virtual machine from the exported checkpoint” -foregroundcolor red -backgroundcolor yellow

Write-Host “`n`$XML = gci `”$ExportPath$DemoVM1\Virtual Machines`” | Where-Object {$_.Extension -eq `”.XML`”}”
$XML = gci “$ExportPath$DemoVM1\Virtual Machines” | Where-Object {$_.Extension -eq “.XML”}

Write-Host “`n`$NewVM = IMPORT-VM -path `$XML.FullName -Copy -VhdDestinationPath `”$ImportVMPath\Virtual Hard Disks`” -VirtualMachinePath `”$ImportVMPath`” -SnapshotFilePath `”$ImportVMPath\Snapshots`” -SmartPagingFilePath `”$ImportVMPath`” -GenerateNewId”
$NewVM = IMPORT-VM -path $XML.FullName -Copy -VhdDestinationPath “$ImportVMPath\Virtual Hard Disks” -VirtualMachinePath $ImportVMPath -SnapshotFilePath “$ImportVMPath\Snapshots” -SmartPagingFilePath $ImportVMPath -GenerateNewId

Write-Host “`nRename-VM `$NewVM $ImportedVMName”
Rename-VM $NewVM $ImportedVMName

Write-Host “`nStart-VM $ImportedVMName”
Start-VM $ImportedVMName

Write-Host “`nHere is the original virtual machine $DemoVM1 and the new virtual machine $ImportedVMName” -foregroundcolor red -backgroundcolor yellow
Get-VM $ImportedVMName,$DemoVM1 | Select Name, Status | Out-Host

#Clean up the demo
Read-Host “`nEnd the demo”
Start-VM $DemoVM1 | Out-Null
If (Test-Path $ExportPath)
{
Remove-Item $ExportPath -Recurse -Force | Out-Null
}
CLS
Remove-VMSnapshot $DemoVM1 -ErrorAction Ignore | Out-Null
Stop-VM $ImportedVMName -Force -ErrorAction Ignore | Out-Null
Remove-VM $ImportedVMName -Force -ErrorAction Ignore | Out-Null
Remove-Item $ImportVMPath -Recurse -Confirm:$false -ErrorAction Ignore | Out-Null

TEE14 Scripted Demo 1 – Guest-Aware NUMA

As promised at Teched Europe 2014, I am sharing each of the PowerShell scripts that I used to drive my feature demos in my session. The first of these scripts focuses on non-uniform memory access, or NUMA.

image

All of my demo scripts work in this kind of fashion:

  1. Clean up the lab
  2. Create demo environment variables for hosts, clusters, machines
  3. Write-Host “some cmdlet and parameters”
  4. Do the cmdlet and some parameters
  5. Optionally display the results
  6. Do more stuff
  7. Clean up the lab.

Most of the code in these scripts is fluff, purely for display and lab prep/reset.

In this script I:

  1. Clean up the lab, ensure the VM (spans NUMA nodes cos of vCPU count) is just the way I want it.
  2. Get the NUMA config of the host.
  3. Get the NUMA config of the VM.
  4. Show that the VM is not NUMA aligned.
  5. Retrieve the VM’s advanced NUMA configuration.
  6. Shutdown the VM, set it to use static memory, and restart it.
  7. Query the VMs NUMA alignment, and see that it is aligned now, but we have use static memory.
  8. Reset the lab back to the start.

CLS
$DemoVM1="NUMA"

#Reset the demo
Stop-VM $DemoVM1 -Force | Out-Null
Set-VMMemory $DemoVM1 -DynamicMemoryEnabled:$true -StartupBytes 512MB -MaximumBytes 8GB -MinimumBytes 256MB
Start-VM $DemoVM1 | Out-Null

#Start the demo
Read-Host "Start the demo"
Write-Host "`nGet-VMHostNumaNode"
Get-VMHostNumaNode
Write-Host "`nThe host has 2 NUMA nodes. Large VMs should also have 2 NUMA nodes for best performance" -foregroundcolor red -backgroundcolor yellow

Read-Host "`nCheck the NUMA and Dynamic Memory configuration of the VM $DemoVM1"
Write-Host "`nGet-VM $DemoVM1 | Select Name, ProcessorCount, MemoryMaximum, DynamicMemoryEnabled, NumaAligned, NumaNodesCount, NumaSocketCount"
Get-VM $DemoVM1 | Select Name, ProcessorCount, MemoryMaximum, DynamicMemoryEnabled, NumaAligned, NumaNodesCount, NumaSocketCount | Out-Host
Write-Host "`nGuest NUMA isn’t alligned and the 24 vCPU virtual machine has only 1 NUMA node" -foregroundcolor red -backgroundcolor yellow

Read-Host "`nGet the advanced NUMA configuration of the VM $DemoVM1"
Write-Host "`nGet-VMProcessor $DemoVM1 | Select Count, MaximumCountPerNumaNode, MaximumCountPerNumaSocket`n"
Get-VMProcessor $DemoVM1 | Select Count, MaximumCountPerNumaNode, MaximumCountPerNumaSocket
Write-Host "`nGet-VMMemory $DemoVM1 | Select MaximumPerNumaNode`n"
Get-VMMemory $DemoVM1 | Select MaximumPerNumaNode
Write-Host "`nThis is the NUMA node configuration that Hyper-V can present to the VM via Guest-Aware NUMA" -foregroundcolor red -backgroundcolor yellow

Read-Host "`nDisable Dynamic Memory for the VM $DemoVM1 & restart it"
Stop-VM $DemoVM1 -Force
Write-Host "`nSet-VMMemory $DemoVM1 -DynamicMemoryEnabled:$false -StartupBytes 8GB"
Set-VMMemory $DemoVM1 -DynamicMemoryEnabled:$false -StartupBytes 8GB
Start-VM $DemoVM1
Write-Host "`nGet-VM $DemoVM1 | Select Name, ProcessorCount, MemoryMaximum, DynamicMemoryEnabled, NumaAligned, NumaNodesCount, NumaSocketCount`n"
Get-VM $DemoVM1 | Select Name, ProcessorCount, MemoryMaximum, DynamicMemoryEnabled, NumaAligned, NumaNodesCount, NumaSocketCount | Out-Host
Write-Host "`nThe VM now is NUMA aligned and has a NUMA configuration that matches the host hardware" -foregroundcolor red -backgroundcolor yellow

#End the demo
Read-Host "`nEnd the demo"
Stop-VM $DemoVM1 -Force
Set-VMMemory $DemoVM1 -DynamicMemoryEnabled:$true -StartupBytes 512MB -MaximumBytes 8GB -MinimumBytes 256MB
Start-VM $DemoVM1 | Out-Null

TEE14–PowerShell Unplugged

Speaker: Jeffrey Snover, uber genius, Distinguished Engineer, and father of PowerShell.

Tale of 3 Parents

  • UNIX: Small unit composition with pipes: A | B | C. Lacks consistency and predictability.
  • VMS/DCL: The consistent predictable nature impacted Jeffrey. Verb & noun model.
  • AS400/CL: Business oriented – enable people to do “real business”.

Keys to Learning PowerShell

  • Learn how to learn: requires a sense of exploration. I 100% agree. That’s what I do: explore the cmdlets and options and properties of objects.
  • Get-Help and Update-Help. The documentation is in the product. The help is updated regularly.
  • Get-Command and Show-Command
  • Get-Member and Show-Object –> the latter is coming.
  • Get-PSDrive HOw hierarchical systems like  drives are explored.

Demo

Into ISE to do some demo stuff.

He uses a OneGet and PowerShellGet modules to pull down modules from trusted libraries on the Internet (v5 from vNext).

Runs Show-Object to open a tree explorer of a couple of cmdlets.

Dir variable …. explore the virtual variable drive to see the already defined variables available to you.

$c = get-command get-help

get-object $c

$c.parameters

$c.parameters.path

get-command –noun disk

Get-something | out-gridview

Get-Help something –ShowWindow

$ConfirmPreference = “Low”

Microsoft News – 24 October 2014

This is the last of my news posts before TechEd Europe. Expect crazy flurries of news on Tuesday morning during the keynote. I’ll be live blogging so my updates will be there.

System Center

Azure

Miscellaneous

Finishing Preparations Of My TechEd Europe Presentation

I am in the midst of finishing off my presentation for TechEd Europe 2014, CDP-B329 From Demo to Reality: Best Practices Learned from Deploying Windows Server 2012 R2 Hyper-V.

as

The session drills into all the things that make previous big announcements & demos possible, and talks about those lesser known features that solve real problems. I’m covering a lot of stuff in this session. I submitted the draft deck a while ago, thinking that I’d have to cull a lot of it to fit within the limit of 75 minutes. Well, I did my first timed rehearsal tonight and I have a bit of wiggle room, maybe to even add in some more demos.

Speaking of which … my demos Open-mouthed smile Fast networking, good host hardware, and LOTS of PowerShell. All my demos are driven by PowerShell. Don’t think “ugh, boring!”. Nope. It’s all very visual, I assure you! There are ways, means, and tricks to show you the goodies even with a scripting language! Heck! PowerShell is even a part of the product that I want to demo! Right now I have 9 demos to show, and that might expand.

If you are coming to TechEd then I hope to see you at CDP-B329. Right now, I’m scheduled for Wednesday morning, but I heard I might be moved to the timeslot of doom on Friday at 08:30 Sad smile Please check the box for my session on the Schedule Builder to try change their mind before the move me!!!!! My session is confirmed for Wednesday at 10:15 in Hall 8.0 Room A2 (seats 1174 people!!!) – hit the schedule builder and check my session (CDP-B329) if it sounds interesting to you.

And by the way – a huge THANK YOU to Didier Van Hoye (aka @workinghardinit at http://workinghardinit.wordpress.com/)  for his help. He helped me sort out some problems in 2 of my demos. Didier is a class example of an MVP working in the community.

Microsoft News Summary – 8 October 2014

Welcome to today’s cloud-heavy Microsoft news compilation.

Windows Server

clip_image001

Windows Client

Azure

  • Introducing the Azure Automation Runbook Gallery: The time it takes to create functional, polished runbooks is a little faster thanks to the new Azure Automation Runbook Gallery.
  • More Changes to Azure by Scott Guthrie: Including support for static private IP support in the Azure Preview Portal, Active Directory authentication, PowerShell script converter, runbook gallery, hourly scheduling support.
  • Microsoft Certification Test Tool Preview for Azure Certified: The Microsoft Certification Test Tool for Azure Certified is designed to provide an assessment of compliance to technical requirements as part of the Azure Certified program. The test tool includes a wizard style automated section and questionnaire section to assess characteristics of a Virtual Machine image running in Microsoft Azure and generate results logs. More information on the Azure Certified program is available.
  • Announcing Support for Backup of Windows Server 2008 with Azure Backup: Due to feedback. Please note that this is x64 only and that there are system requirements.
  • Hybrid Connection Manager ClickOnce Application: ClickOnce installer for the Hybrid Connection Manager.
  • D-Series Performance Expectations: The new D-Series VMs provide great performance for applications needing fast, local (ephemeral) storage or a faster CPU; however, it’s important to understand a little about how the system is configured to ensure you’re getting an optimal experience.
  • Cloud App Discovery – Now with Excel and PowerBI Support: One of the top customer requests was to be able to perform analytics on the data collected in tools like Excel and PowerBI. Now you can take cloud app discovery data offline and explore and analyze the data with tools you already know–Excel and PowerBI.
  • A new region will open in India by the end of 2015: It makes sense; there are 1 billion people and some big corporations there.
  • Microsoft Azure Speed Test: Which Azure region is closest to you (remember that Internet geography is different to the planet’s geography. For example, where I work is a few miles from Europe North (Dublin), but the test shows me that Europe West provides me with lower latency (beaten, obviously, by CDN). My own testing using Azure Traffic Manager with geo-dispersed websites has verified this.

clip_image002

Office 365

Miscellaneous

Microsoft News Summary – 1 October 2014

There’s not all that much news to cover this morning. Oh … hold on …

Hyper-V

Windows Server

clip_image001

Windows Client

clip_image002

System Center

Azure

Security

Office 365

  • Delivering the first chapter of Groups in Office 365: Grouping of users will be rolled out to all customers that have an Exchange Online or Office 365 commercial subscription, both new and existing. Eligible Office 365 plans include the Office 365 Enterprise E1–E4 subscription plans (including the corresponding A2–A4 and G1–G4 plans for Academic and Government customers, respectively), Office 365 Business Essentials and Business Premium plans, Office 365 Small Business, Small Business Premium and Midsize Business plans and Office 365 Kiosk plan.
  • Step-By-Step – Setting up the new Azure AD Sync Tool: AAD Sync is Microsoft’s new directory synchronization tool that simplifies the process of connecting Azure AD to Windows Server AD. It also makes it more simple to connect complex, multi-forest deployments.

The Funnies

  • America’s CBS attempts to out-dumb CNN:

clip_image003

Microsoft News Summary – 19 September 2014

The positive highlight for me is the excellent TechNet article on managing tiered Storage Spaces. The lowlight was the unannounced price changes in Azure – (A) it was unannounced (B) there was no notice, and (C) it means that customers cannot plan; customers hate each and every one of those, especially the latter.

Hyper-V

Window Server

Windows

  • The September 30th Microsoft Event: Paul Thurrott (on Windows Weekly) confirmed that this event will not be streamed. Major mistake in my opinion. The attendees are a small set of media, and the subject matter is Windows “Threshold” in the enterprise. Sure … let’s not let the IT pros who will make the recommendation see the event. That’s reeeealllly sensible. Let the Windows 8 insanity continue.

Azure

Office 365

    clip_image001

Licensing

  • SPLA Audit start to finish: SPLA is based on an honour system – but audits have become a way of life with such licensing programs.

Miscellaneous

Microsoft News Summary – 10 September 2014

In other news, Apple proves that wearable devices are a pointless Gartner-esque fad, and those preachy tax-avoiding frakkers, U2, suck donkey balls.

Hyper-V

System Center Operations Manager

  • OM12 Sizing Helper: This is a Windows Phone app version of the OpsMgr 2012 Sizing Helper document.

Azure

Miscellaneous

  • Microsoft rumored to be poised to buy Minecraft creator for $2 billion: This blocky game is the hottest thing with kids. I’ve spent many an hour *cough* helping *yes, helping* with constructions & adventures on an iPad and Xbox. And to be honest, it is a good problem solving game and it encourages kids to interact, based on what I’ve observed.

Microsoft News Summary – 9 September 2014

It’s a slow day, so here’s your updates for today. I think the Azure Automation post should be useful – I’ll sure be ripping it off inspired by it for future demos Smile

Hyper-V

Azure

Licensing