Fix powershell formatting. Match style for conditionals

This commit is contained in:
DanHam 2019-09-09 23:05:40 +01:00
parent dad3ae1535
commit 2b6286c31c
No known key found for this signature in database
GPG Key ID: 58E79AEDD6AA987E
1 changed files with 10 additions and 12 deletions

View File

@ -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
}
}