question

RogerRoger-2394 avatar image
0 Votes"
RogerRoger-2394 asked RichMatheisen-8856 edited

Set from Static to DHCP

Hi All

i have few windows 10 machines in a csv file. i want to set the ip from static to DHCP on these machines, how do i do it from powershell. experts guide me. my csv file is in below format

vm1.contoso.com
vm2.contoso.com
vm3.contoso.com

windows-server-powershellwindows-server-2019windows-server-2016windows-server-2012windows-dhcp-dns
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

RichMatheisen-8856 avatar image
0 Votes"
RichMatheisen-8856 answered RichMatheisen-8856 edited

Is your DHCP also going to be provisioning the gateway address? If it is you'll need to do two things:

 Set-NetIPInterface -InterfaceAlias 'Ethernet 1' -Dhcp Enabled

and:

 Get-NetIPAddress -InterfaceAlias 'Ethernet 1' | Remove-NetRoute

Also, knowing just the name of the machine isn't enough. You'll also have to provide the name of the NIC you want to change, and that may be different on each machine.

When you change the IP address you're going to be disconnected, so build that problem into the script you write.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

GaryReynolds avatar image
0 Votes"
GaryReynolds answered

Hi,

Have a look at this page which has details of the add-dhcpserverv4reservation command, which includes some sample scripts on how to import from a file.

https://docs.microsoft.com/en-us/powershell/module/dhcpserver/add-dhcpserverv4reservation?view=windowsserver2019-ps

Gary.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.