Remove NetIPAddress - PowerShell
Overview
The Remove-NetIPAddress
command removes IP addresses from an existing network interface. It can be used to remove both IPv4 and IPv6 addresses.
Syntax
Remove-NetIPAddress [-InterfaceAlias] <String> [-IPAddress] <String[]> [-Confirm] [-WhatIf] [-PassThru]
Options/Flags
- -InterfaceAlias: The alias of the network interface from which to remove the IP addresses.
- -IPAddress: The IP addresses to remove from the network interface. You can specify multiple IP addresses by using a comma-separated list.
- -Confirm: Prompts you for confirmation before executing the command.
- -WhatIf: Shows what the command would do without actually executing it.
- -PassThru: Returns the network interface object after removing the IP addresses.
Examples
Example 1: Remove an IPv4 address from a network interface
Remove-NetIPAddress -InterfaceAlias "Ethernet" -IPAddress "192.168.1.10"
Example 2: Remove multiple IPv6 addresses from a network interface
Remove-NetIPAddress -InterfaceAlias "Ethernet" -IPAddress "2001:db8::1", "2001:db8::2"
Common Issues
- If the network interface does not exist, the command will fail.
- If the IP address is not assigned to the network interface, the command will fail.
Integration
The Remove-NetIPAddress
command can be used with other PowerShell commands to manage network interfaces. For example, you can use the Get-NetIPAddress
command to get a list of the IP addresses assigned to a network interface, and then use the Remove-NetIPAddress
command to remove the IP addresses you no longer need.
Related Commands
Add-NetIPAddress
Get-NetIPAddress