April 2024
M T W T F S S
1234567
891011121314
15161718192021
22232425262728
2930  

Categories

April 2024
M T W T F S S
1234567
891011121314
15161718192021
22232425262728
2930  

Add A DHCP using PowerShell

Here is a quick powershell script to set your network card TCP/IP setting to dynamic addressing:

$NICs = Get-WMIObject Win32_NetworkAdapterConfiguration | where{$_.IPEnabled -eq “TRUE”}

Foreach($NIC in $NICs)

{

$NIC.EnableDHCP()

$NIC.SetDNSServerSearchOrder()

}

IPConfig /all

Add A Static IP using PowerShell

$NICs = Get-WMIObject Win32_NetworkAdapterConfiguration -computername . | where{$_.IPEnabled -eq $true -and $_.DHCPEnabled -eq $true} Foreach($NIC in $NICs) { $ip = “192.168.1.10” $gateway = “192.168.1.254” $subnet = “255.255.255.0” $dns = “8.8.8.8”,”192.168.1.254″ $NIC.EnableStatic($ip, $subnet) $NIC.SetGateways($gateway) $NIC.SetDNSServerSearchOrder($dns) $NIC.SetDynamicDNSRegistration(“FALSE”) } IPConfig /all