Skip to content

Instantly share code, notes, and snippets.

@Recast-team
Created December 7, 2019 06:25
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Recast-team/c76fce8ba772d0319befd416b761cea9 to your computer and use it in GitHub Desktop.
Save Recast-team/c76fce8ba772d0319befd416b761cea9 to your computer and use it in GitHub Desktop.
$NetworkInfo = Get-CimInstance Win32_NetworkAdapterConfiguration | Where-Object {$_.DHCPEnabled -eq $false}
#Setup TS Environment
try
{
$tsenv = New-Object -COMObject Microsoft.SMS.TSEnvironment
}
catch
{
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