Sunday 16 September 2012

New-InternalSwitch.ps1

  1. <#
  2. .SYNOPSIS
  3.     This script demonstrates creating a Hyper-V Switch
  4. .DESCRIPTION
  5.     This script imports the Hyper-V module then uses it
  6.     to create an Internal Switch for use in future provisioning.
  7. .NOTES
  8.     File Name : New-InternalSwitch.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.     C:\foo\> .New-InternalSwitch.ps1
  16.     VERBOSE: New-InternalSwitch will create a new virtual network.
  17.     Name      SwitchType NetAdapterInterfaceDescription
  18.     ----      ---------- ------------------------------
  19.     Internal  Internal
  20. #>
  21. # Import Hyper-V Module
  22. Import-Module Hyper-V
  23. Try {New-VMSwitch -Name Internal -SwitchType Internal -ComputerName LocalHost -Verbose}
  24. Catch { "Failed to create switch"; $error[0] }
  25. # End New-InternalSwitch.ps1

No comments: