vagrant/plugins/providers/hyperv/scripts/get_network_config.ps1

18 lines
442 B
PowerShell
Raw Normal View History

2014-02-26 19:12:24 +00:00
Param(
[Parameter(Mandatory=$true)]
[string]$VmId
)
# Include the following modules
2014-02-26 19:12:24 +00:00
$Dir = Split-Path $script:MyInvocation.MyCommand.Path
. ([System.IO.Path]::Combine($Dir, "utils\write_messages.ps1"))
2014-02-26 19:12:24 +00:00
$vm = Get-VM -Id $VmId -ErrorAction "Stop"
$network = Get-VMNetworkAdapter -VM $vm
$ip_address = $network.IpAddresses[0]
$resultHash = @{
ip = "$ip_address"
}
2014-02-26 19:12:24 +00:00
$result = ConvertTo-Json $resultHash
Write-Output-Message $result