Forum Discussion
How to change IP Address using Set-NetIPAddress
Hi,
Wondering how to use cmdlet Set-NetIPAddress to change the current config.
I Don't want to ADD new IP to the interface using New-NetIPAddress cmdlet.
May somebody could help me?
Thanks.
2 Replies
- DarrickBrass Contributor
What have you tried and with what results?
- Sean KearneyFormer Employee
You'll probably need to use Two Cmdlets to modify the Current Configuration.
The first is Get-NetAdapter.
This will display all Physical Adapters
Get-NetAdapter -physical
This will display all Physical Adapters which are "live" (Lan Connected)
Get-NetAdapter -physical | Where-Object { $_.Status -ne 'Disconnected' }
The trick is figuring out if you have a pile of cards connected, you'd have to filter on either the TEAM Description or the LAN Adapter Description.
Each Network card has a property called the "InterfaceIndex". Once you know which card you're trying to re-configure it's a matter of using the InterfaceIndex Property with the Set-NetIPAddress Cmdlet to update the value of the Network Card.
Example - Changing to a StaticIP address of 10.0.0.5 with a subnet mask of 255.255.255.0 (24 bits) on Interface Index 6
Set-NetIPAddress -InterfaceIndex 6 -IPAddress 10.0.0.5 -PrefixLength 24
Sean