Created
December 7, 2019 06:25
-
-
Save Recast-team/c76fce8ba772d0319befd416b761cea9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$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