This topic contains 3 replies, has 4 voices, and was last updated by
January 10, 2019 at 11:48 am #133770ParticipantTopics: 1Replies: 0Points: -9Rank: Member
Pretty much as the title says.
as it is now there is no default gateway appearing in PowerShell so I guess I'm adding a new one and not changing an old one. The subnet mask needs to change from 255.255.255.255 to 255.255.255.0 . Should this happen automatically when the IP address gets changed or when when the default gateway gets changed?
there doesn't seem to be a lot of info on subnet mask that's why I'm just assuming it should just change automatically. but I could be wrong
January 10, 2019 at 12:16 pm #133842ParticipantTopics: 1Replies: 1430Points: 2,128Rank: Community Hero
As far as I know Powershell does not need a separate IP configuration. It uses the existing IP stack of the underlying Windows. You might elaborate more in detail about the reason for your question.
January 10, 2019 at 4:02 pm #133893ParticipantTopics: 0Replies: 78Points: 423Rank: Contributor
When you are trying to change the IPAddress, SubnetMask/PrefixLength, DefaultGateway and DNSServer using PowerShell, that you need to add the addresses for each, it will not auto-populate.
PS C:\> New-NetIPAddress -InterfaceIndex 12 -IPAddress 192.168.1.20 -PrefixLength 24 -DefaultGateway 192.168.1.1 PS C:\> Set-DnsClientServerAddress -InterfaceIndex 12 -ServerAddresses 192.168.1.100,192.168.1.200
January 11, 2019 at 12:50 am #133955ParticipantTopics: 2Replies: 990Points: 1,895Rank: Community Hero
If this is a corporate environment, this is normally handled by your DHCP server.
Just do a release all on the IPAddress on the host and a renew or restart the computer.
If you are in a workgroup, then of course you need PSRemoting setup to use the Net-* cmldets to set what you are after, but even that, you need to be on the same IPRange for your workstation and the remote host.
If you are on your own workstation, just use the GUI to do this, unless you are saying you need to do this a lot then automation would be prudent.
The topic ‘How to Change Default gateway and subnet mask in PowerShell’ is closed to new replies.