Created
November 16, 2018 05:39
-
-
Save kskmori/0665459c702003d7141ddaf0943b7615 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# invoke as: | |
# powershell -NoProfile -ExecutionPolicy Unrestricted -NonInteractive .\findif.ps1 | |
# | |
Param( | |
[Parameter(Mandatory=$True,Position=1)][string]$IPAddress, | |
[Parameter(Mandatory=$True,Position=2)][string]$InterfaceAddress | |
) | |
# check if the ipaddr is already assigned | |
$ifindex = (Get-NetIPAddress | where IPAddress -eq $IPAddress).InterfaceIndex | |
Write-Host "ifindex = " $ifindex | |
if ($ifindex -eq $null) { | |
# find the interface by InterfaceAddress | |
$ifindex = (Get-NetIPAddress | where IPAddress -eq $InterfaceAddress).InterfaceIndex | |
Write-Host "ifindex = " $ifindex | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment