PowerShell stuph...: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
| Line 2: | Line 2: | ||
= Scripts i (ab)use = | = Scripts i (ab)use = | ||
<div class="toccolours mw-collapsible mw-collapsed"> | |||
==== Config NIC as DHCP Client ==== | ==== Config NIC as DHCP Client ==== | ||
<div class="mw-collapsible-content"> | |||
<pre>$IPType = "IPv4" | <pre>$IPType = "IPv4" | ||
| Line 20: | Line 22: | ||
$interface | Set-DnsClientServerAddress -ResetServerAddresses | $interface | Set-DnsClientServerAddress -ResetServerAddresses | ||
}</pre> | }</pre> | ||
</div> | |||
</div> | |||
[[Category:Windows]] | [[Category:Windows]] | ||
Revision as of 13:38, 16 November 2016
Scripts i (ab)use
Config NIC as DHCP Client
$IPType = "IPv4"
$adapter = Get-NetAdapter | ? {$_.Status -eq "up"}
$interface = $adapter | Get-NetIPInterface -AddressFamily $IPType
If ($interface.Dhcp -eq "Disabled") {
# Remove existing gateway
If (($interface | Get-NetIPConfiguration).Ipv4DefaultGateway) {
$interface | Remove-NetRoute -Confirm:$false
}
# Enable DHCP
$interface | Set-NetIPInterface -DHCP Enabled
# Configure the DNS Servers automatically
$interface | Set-DnsClientServerAddress -ResetServerAddresses
}