Sunday 16 September 2012

Set-HyperVHostDefault.ps1

  1. <# 
  2. .SYNOPSIS 
  3.     This script demonstrates setting default values for Local Hyper-V host. 
  4. .DESCRIPTION 
  5.     This script imports the Hyper-V module then uses it 
  6.     to set certain default values for this hyper-V Host 
  7. .NOTES 
  8.     File Name  : Set-HyperVHostDefault.ps1 
  9.     Author     : Thomas Lee - tfl@psp.co.uk 
  10.     Requires   : PowerShell Version 3.0 and Windows 8/Server 2012 
  11. .LINK 
  12.     This script posted to: 
  13.         http://www.pshscripts.blogspot.com 
  14. .EXAMPLE 
  15.    Left as an exercise for the reader 
  16.     
  17. #> 
  18.  
  19.  
  20. # Import Hyper-V Module 
  21. Import-Module Hyper-V 
  22.  
  23. Write-Verbose "$((gcm -module hyper-v).Count) cmdlets imported in Hyper-V Module" 
  24.  
  25. # Create $parm hash table! 
  26. $parm = @{} 
  27.  
  28. # Specify the Computername 
  29. $parm += @{ComputerName = "Win8.Cookham.Net"
  30.  
  31. # Specify the Hard Disk Path 
  32. $parm += @{VirtualMachinePath = "E:\hyperv"
  33.  
  34. # Specify the VHD Disk Path 
  35. $parm += @{VirtualHardDiskPath = "E:\hyperv"
  36.  
  37. # Set the VM host accordingly 
  38. Write-Verbose "Setting parameters as follows:";$parm 
  39. Set-VmHost @parm 
  40.  
  41. # And Display Details 
  42.  
  43. Get-VMHost 
  44.  
  45. # End Set-HyperVHostDefaults 

No comments: