Do stuff if computer is on a certain subnet during OSD

For our new machines they will be getting OSD'd offsite so we want to  skip some task sequence steps such as our login to AD security check before imaging.

This can easily be achieved using CustomSettings.ini with MDT but in some scenarios you may need to do this before loading MDT. The script sets a variable if the gateway matches:

$tsenv = New-Object -COMObject Microsoft.SMS.TSEnvironment
 (Get-wmiObject Win32_networkAdapterConfiguration | ?{$_.IPEnabled}) | foreach {

 If ($_.DefaultIPGateway -eq "123.456.678.254")
    Write-Host "Offsite Gateway"
    $tsenv.Value("Offsite") = "True"
    Write-Host "Other Gateway"
    $tsenv.Value("Offsite") = "False"

Once we have this, we can skip steps or run steps if the conditions match

X:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy Unrestricted -NoProfile -File X:\scripts\Test-Gateway.ps1

test1 Task Sequence rules

Further more you could store this variable in the reg and report  on it later ie; count of machines imaged at that place.



UPDATE: @pvanderwoude informed me this can be easily achieved using dynamic variables, still good if on ConfigMgr 2007 🙂

There are no comments yet, add one below.

Leave a Comment

Your email address will not be published. Required fields are marked *