Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Microsoft Hyper-V PowerShell Automation

You're reading from   Microsoft Hyper-V PowerShell Automation Manage, automate, and streamline your Hyper-V environment effectively with advanced PowerShell cmdlets

Arrow left icon
Product type Paperback
Published in Jan 2015
Publisher
ISBN-13 9781784391539
Length 124 pages
Edition 1st Edition
Tools
Arrow right icon
Author (1):
Arrow left icon
Vinith Menon Vinith Menon
Author Profile Icon Vinith Menon
Vinith Menon
Arrow right icon
View More author details
Toc

Table of Contents (8) Chapters Close

Preface 1. New PowerShell Cmdlets in Hyper-V on Windows Server 2012 R2 FREE CHAPTER 2. Managing Your Hyper-V Virtual Infrastructure 3. Managing Your Hyper-V Virtual Machines 4. Creating Reusable PowerShell Scripts Using Hyper-V PowerShell Module Cmdlets 5. The Next Step – Integration with SCVMM 6. Troubleshooting Hyper-V Environment Issues and Best Practices Using PowerShell Index

Updated features for exporting a virtual machine

With the updated Hyper-V features in Windows Server 2012 R2, you can export a live VM and its snapshot without shutting down the VM, which had to be done in Windows 2012. This helps the administrator to avoid unnecessary downtime for the virtual machine export. There are two cmdlets that can be used for the live export of virtual machines and its snapshots; these are the Export-VM and the Export-VMSnapshot cmdlets.

The Export-VM cmdlet exports a virtual machine to disk. This cmdlet creates a folder at a specified location with three subfolders: Snapshots, Virtual Hard Disks, and Virtual Machines. The Snapshots and Virtual Hard Disks folders contain the snapshots and the VHDs of the specified virtual machine respectively. The Virtual Machines folder contains the configuration XML of the specified virtual machine. The following command exports all virtual machines to root of the D drive. Each virtual machine will be exported to its own folder:

Get-VM | Export-VM –Path D:\

The export of a live VM is very different from the export of a snapshot of a live VM. The export of a live VM can be done by creating a snapshot first, then exporting it, and then finally removing the snapshot. The following cmdlet shows you how to do this:

Get-VM | Checkpoint-VM| Export-VMSnapshot -path d:\ | Remove-VMSnapshot 

The Export-VMSnapshot cmdlet exports a virtual machine snapshot to disk:

PS C:\>Export-VMSnapshot –Name 'Base Image' –VMName TestVM –Path D:\

The preceding command exports the Base Image snapshot of the TestVM virtual machine to D:\.

You have been reading a chapter from
Microsoft Hyper-V PowerShell Automation
Published in: Jan 2015
Publisher:
ISBN-13: 9781784391539
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image