November 2024
M T W T F S S
 123
45678910
11121314151617
18192021222324
252627282930  

Categories

November 2024
M T W T F S S
 123
45678910
11121314151617
18192021222324
252627282930  

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