Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
$NetworkInfo = Get-CimInstance Win32_NetworkAdapterConfiguration | Where-Object {$_.DHCPEnabled -eq $false}
#Setup TS Environment
$tsenv = New-Object -COMObject Microsoft.SMS.TSEnvironment
Write-Verbose "Not running in a task sequence."
$tsenv.value('OSDAdapter0IPAddressList') = $NetworkInfo.IPAddress[0]
$tsenv.value('OSDAdapter0SubnetMask') = $NetworkInfo.IPSubnet[0]
$tsenv.value('OSDAdapter0Gateways') = $NetworkInfo.DefaultIPGateway[0]
$tsenv.value('OSDAdapter0DNSServerList') = $NetworkInfo.DNSServerSearchOrder[0]
$tsenv.value('OSDAdapter0DNSSuffix') = $NetworkInfo.DNSDomainSuffixSearchOrder[0]
if ($NetworkInfo.DHCPEnabled -eq $false)
$tsenv.value('OSDAdapterCount') = 1
$tsenv.value('OSDAdapter0EnableDHCP') = $false
else {$tsenv.value('OSDAdapter0EnableDHCP') = $true}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.