http://blogs.technet.com/b/heyscriptingguy/archive/2013/01/24/use-powershell-to-change-ip-behavior-with-skipassource.aspx
KB969029
Thank you James Kehr
# set some constants clear Import-Module NetTCPIP Get-NetIPAddress | Where {$_.PrefixOrigin -eq "Manual"} | select IPaddress,InterfaceAlias,SkipasSource | format-table $primaryIP = Read-Host "Which ip address should be set as primary?" $Alias = Get-NetIPAddress $primaryIP -EA stop | select -expand InterfaceAlias Write-Host "Setting $Alias primary IP to $primaryIP" # get all the IP addresses on the interface, filtered by IPv4 and excluding # the $primaryIP [array]$IPs = Get-NetIPAddress -InterfaceAlias $Alias | Where-Object {$_.AddressFamily -eq "IPv4" -and $_.IPAddress -ne $primaryIP} # set primary IP SkipAsSource to false Set-NetIPAddress -IPAddress $primaryIP -InterfaceAlias $Alias -SkipAsSource $false # set other IP addresses with SkipAsSource equal to true Set-NetIPAddress -IPAddress $IPs.IPAddress -InterfaceAlias $Alias -SkipAsSource $true Write-Host "Please review the output False under SkipasSource means the ip can be a source" Get-NetIPAddress | Where {$_.PrefixOrigin -eq "Manual"} | select IPaddress,InterfaceAlias,SkipasSource | format-table
No comments:
Post a Comment