PowerShell learning------hpyer-v Virtual machine optimization (backup, compressed disk)

Source: Internet
Author: User

Learn about Robin's blog post, the original address   below is his summary automation management is becoming more and more common,hyper-v  virtual machines also can. Premise:   system server 2008 above,powershell 3.0,  import Hyper-V Library 1. Virtual Machine Automatic backup set-executionpolicy  unrestricted     #信任脚本Import-module d:\hyperv\hyperv\hyperv.psd1  # Every execution to the import library   $BackupDriver  =  "E:"              #备份驱动盘符   $BackupFolder  = $ (get-date -uformat  "%y%m%d")     #备份文件夹名, Format is date new-item -path  $BackupDriver  -name  $BackupFolder  -type directory    $VM  =  "XPx32", "win7x64"      #分别备份  hyper-v the name of the virtual machine foreach ($i  in   $VM) {  shutdown-vm  $i  -FORCE  START-SLEEP 30  EXPORT-VM   $i   $BackupDriver \ $BackupFolder \ $i "_" $ (get-date -uformat  "%y%m%d%h%m")  -copystate  –wait  Start-Sleep 60  start-vm  $i   start-sleep 60  }  2.  virtual machine hard disk compression The following is a compressed command of the virtual machine hard disk compact-vhd  and  COMPRESS-VHD can be implemented, the same functionality. With regard to the use of the actual production, I recommend to perform in idle time. I usually continue after the patch update so after compressing the backup VM, can also automate execution, the ultimate goal is to optimize the Hyper-V virtual machine   Compress -VHD -VHDPaths  ' e:\ Hyperv_runing\vhd\xpx32.vhd '   #compress  vhd  compressed disk   The path to the virtual machine disk: ' E:\HyperV_Runing\VHD\XPx32.vhd ' Get-wmiobject -namespace root\virtualization msvm_storagejob | ft jobstatus,  description, percentcomplete -auto   #compress  status View background compression

PowerShell learning------hpyer-v Virtual machine optimization (backup, compressed disk)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.