From 2b6286c31c4bb6d5460400c7a7d46a5724877c60 Mon Sep 17 00:00:00 2001 From: DanHam Date: Mon, 9 Sep 2019 23:05:40 +0100 Subject: [PATCH] Fix powershell formatting. Match style for conditionals --- common/powershell/hyperv/hyperv.go | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/common/powershell/hyperv/hyperv.go b/common/powershell/hyperv/hyperv.go index e93a885eb..15d8d92b1 100644 --- a/common/powershell/hyperv/hyperv.go +++ b/common/powershell/hyperv/hyperv.go @@ -35,21 +35,19 @@ param([string]$switchName, [int]$addressIndex) $HostVMAdapter = Hyper-V\Get-VMNetworkAdapter -ManagementOS -SwitchName $switchName if ($HostVMAdapter){ $HostNetAdapter = Get-NetAdapter | Where-Object { $_.DeviceId -eq $HostVMAdapter.DeviceId } - if ($HostNetAdapter){ - $HostNetAdapterIfIndex = @() - $HostNetAdapterIfIndex += $HostNetAdapter.ifIndex - $HostNetAdapterConfiguration = @(get-wmiobject win32_networkadapterconfiguration -filter "IPEnabled = 'TRUE'") | Where-Object { $HostNetAdapterIfIndex.Contains($_.InterfaceIndex) } - if ($HostNetAdapterConfiguration){ - return @($HostNetAdapterConfiguration.IpAddress)[$addressIndex] - } - } -} -else { + if ($HostNetAdapter){ + $HostNetAdapterIfIndex = @() + $HostNetAdapterIfIndex += $HostNetAdapter.ifIndex + $HostNetAdapterConfiguration = @(get-wmiobject win32_networkadapterconfiguration -filter "IPEnabled = 'TRUE'") | Where-Object { $HostNetAdapterIfIndex.Contains($_.InterfaceIndex) + if ($HostNetAdapterConfiguration){ + return @($HostNetAdapterConfiguration.IpAddress)[$addressIndex] + } + } +} else { $HostNetAdapterConfiguration=@(Get-NetIPAddress -CimSession $env:computername -AddressFamily IPv4 | Where-Object { ( $_.InterfaceAlias -notmatch 'Loopback' ) -and ( $_.SuffixOrigin -notmatch "Link" )}) if ($HostNetAdapterConfiguration) { return @($HostNetAdapterConfiguration.IpAddress)[$addressIndex] - } - else { + } else { return $false } }