Skip to content

Instantly share code, notes, and snippets.

@gyakkun
Created April 5, 2023 08:16
Show Gist options
  • Save gyakkun/be107488132b0cd91a4063d662ef6521 to your computer and use it in GitHub Desktop.
Save gyakkun/be107488132b0cd91a4063d662ef6521 to your computer and use it in GitHub Desktop.
remove-invalid-ipv6-address
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