Created
April 5, 2023 08:16
-
-
Save gyakkun/be107488132b0cd91a4063d662ef6521 to your computer and use it in GitHub Desktop.
remove-invalid-ipv6-address
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
while(1){ | |
# Get-NetIPAddress -AddressFamily IPv6 -InterfaceAlias "LAN" -PrefixOrigin RouterAdvertisement | Sort-Object -Property ValidLifetime -Descend | Select-Object -skip 1 | Remove-NetIPAddress -Confirm:$false | |
$addressToRemove = Get-NetIPAddress -AddressFamily IPv6 -InterfaceAlias "LAN" -PrefixOrigin RouterAdvertisement | Sort-Object -Property ValidLifetime -Descend | Select-Object -skip 1 | |
echo $addressToRemove.Length | |
if( $addressToRemove ){ | |
$addressToRemove | Remove-NetIPAddress -Confirm:$false | |
echo Removed $addressToRemove | |
} | |
echo keep-alive | |
Start-Sleep -Seconds 5 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment