Powershell – Set Remote Computer To DHCP Enabled Without Using WinRM

dhcpnetshpowershell

How can I set a remote computer to use DHCP instead of a static IP address?

I have tried using Set-NetIPInterface -DHCP Enabled however this requires WinRM which is disabled on my network.

How can I do it using a built in Windows technology like Netsh (I can't download PSExec).

Best Answer

WMI works well:

$networkAdapterConfig = Get-WmiObject -Class Win32_NetworkAdapterConfiguration -ComputerName 'SomeComputerName'
$networkAdapterConfig.EnableDhcp()