Wechsel zwischen DHCP und statischer IP-Adresse
$config = Get-WmiObject Win32NetworkadapterConfiguration -Filter "IPEnabled=true" | where { $.Description -like "*Controller #2*" }
"DHCP-Status Vorher: " + $Config.dhcpenabled
Get-WmiObject Win32_Networkadapterconfiguration -Filter "IPEnabled=true" | select Description,IPAddress
if (!$Config.dhcpenabled)
{
"Aktiviere DHCP..."
$Config.EnableDHCP()
}
else
{
"Aktiviere Statische IP-Addresse..."
[array] $ip = "192.168.1.15"
[array] $subnet = "255.255.255.0"
$Config.EnableStatic($ip, $subnet)
}
$config = Get-WmiObject Win32NetworkadapterConfiguration -Filter "IPEnabled=true" | where { $.Description -like "*Controller #2*" }
"DHCP-Status nachher: " + $Config.dhcpenabled
Get-WmiObject Win32_Networkadapterconfiguration -Filter "IPEnabled=true" | select Description,IPAddress