Merge pull request #6232 from mirthy/windows7-hostinfo
FIX: Use a .NET API call instead of a Win8+ cmdlet
This commit is contained in:
commit
fbe10cf7f6
|
@ -1,11 +1,21 @@
|
|||
$ErrorAction = "Stop"
|
||||
|
||||
$net = Get-NetIPAddress | Where-Object {
|
||||
($_.IPAddress -ne "127.0.0.1") -and ($_.IPAddress -ne "::1")
|
||||
} | Sort-Object $_.AddressFamily
|
||||
|
||||
$result = @{
|
||||
ip_addresses = $net.IPAddress
|
||||
}
|
||||
|
||||
Write-Output $(ConvertTo-Json $result)
|
||||
$ErrorAction = "Stop"
|
||||
|
||||
# Find all of the NICsq
|
||||
$nics = [System.Net.NetworkInformation.NetworkInterface]::GetAllNetworkInterfaces()
|
||||
|
||||
# Save the IP addresses somewhere
|
||||
$nic_ip_addresses = @()
|
||||
|
||||
foreach ($nic in $nics) {
|
||||
$nic_ip_addresses += $nic.GetIPProperties().UnicastAddresses | Where-Object {
|
||||
($_.Address.IPAddressToString -ne "127.0.0.1") -and ($_.Address.IPAddressToString -ne "::1")
|
||||
} | Select -ExpandProperty Address
|
||||
}
|
||||
|
||||
$nic_ip_addresses = $nic_ip_addresses | Sort-Object $_.AddressFamily
|
||||
|
||||
$result = @{
|
||||
ip_addresses = $nic_ip_addresses.IPAddressToString
|
||||
}
|
||||
|
||||
Write-Output $(ConvertTo-Json $result)
|
||||
|
|
Loading…
Reference in New Issue