providers/hyperv: add script to read switches

This commit is contained in:
Mitchell Hashimoto 2014-02-26 23:47:28 -08:00
parent da58f7bdc0
commit 3ddc63c88f
2 changed files with 15 additions and 3 deletions

View File

@ -0,0 +1,8 @@
# This will have a SwitchType property. As far as I know the values are:
#
# 0 - Private
# 1 - Internal
#
$Switches = @(Get-VMSwitch `
| Select-Object Name,SwitchType,NetAdapterInterfaceDescription)
Write-Output $(ConvertTo-JSON $Switches)

View File

@ -2,7 +2,9 @@ Param(
[Parameter(Mandatory=$true)]
[string]$vm_xml_config,
[Parameter(Mandatory=$true)]
[string]$vhdx_path
[string]$vhdx_path,
[string]$switchname=$null
)
# Include the following modules
@ -41,8 +43,10 @@ $MemoryMaximumBytes = ($memory.limit."#text" -as [int]) * 1MB
$MemoryStartupBytes = ($memory.size."#text" -as [int]) * 1MB
$MemoryMinimumBytes = ($memory.reservation."#text" -as [int]) * 1MB
if (!$switchname) {
# Get the name of the virtual switch
$switchname = (Select-Xml -xml $vmconfig -XPath "//AltSwitchName").node."#text"
}
# Determine boot device
Switch ((Select-Xml -xml $vmconfig -XPath "//boot").node.device0."#text") {