One of my SCCM Site Servers manages workstations in two different Active Directory sites. One site sits in the Eastern Standard time zone, while the other is in the Arizona time zone. Up until now, all my task sequences have had to be duplicated, one for each time zone, all of which advertised to the Unknown Computers collection. Needless to say, this made a mess of a list when you would boot a computer into WinPE to image the workstation. The end goal that I wanted was one task sequence to be advertised to the Unknown Computers collection and it just automatically go when a computer boots to WinPE, assigning time zones and computers names according to the physical location of the workstation.
So, with knowing what I wanted in mind, I started searching for how I could do it. I knew right off the bat that I would need to create a condition in the task sequence. At first I tried create a WMI condition, but that didn't work for whatever reasons, so I started looking into task sequence variables. I quickly found how to set a task sequence variable in VBScript, and started messing with creating a VBScript that could get the IP address of the workstation it ran on, then determine what site it's in and assign the TS variable accordingly. Unfortunately I suck at VBScript, and had to keep going to a friend for assistance. After a week of that and still no solution I decided to go after PowerShell. I started out in PowerShell having it query WMI for the IP address, then using If Then statements to determine what site it was in. At the end if the site was columbus, the TS Variable would be made Columbus, if the site was Pheonix, obviously the TS Variable was that as well. Below is the code at that point.
Location1.ps1 (Stripped down version)
$wmi = gwmi -q "Select * from Win32_NetworkAdapterConfiguration where IPEnabled = True"if ( $wmi.IPAddress -like "10.15.20*")
{$local = "Columbus"}
else
{$temp = "NotColumbus"}
if ( $wmi.IPAddress -like "10.15.36*")
{$local = "Phoenix"}
else
{$temp = "NotPhoenix"}
$tsenv = New-Object -COMObject Microsoft.SMS.TSEnvironment
$tsenv.Value("location") = "$local"
The above script works fine it your dealing with workstations with only 1 NIC 100% of the time. If at any time a workstation with more than 1 NIC (even wireless cards (laptops)) try to run this, they fail. I believe they fail because the second NIC (even though it's not plugged into anything or connected to a wireless network) is still IPEnabled and that's what the above script looks for. At that point I got a suggestion off Experts Exchange to have it exclude adapters that have an IP Address of 0.0.0.0. At first I thought this would work great. Half way through testing it I realized that it wouldn't fix the issue because there's no IP address assigned to the second network card. But, below is the modified part of the original script.
location2.ps1 (only the modified section)
$wmi = gwmi -q "Select * from Win32_NetworkAdapterConfiguration where IPEnabled = true" | ? {$_.IPAddress -ne "0.0.0.0"}After the above also wasn't working, I decided I needed to go a differant direction with how I was pulling the IP Address information. I tried to change the way I was querying WMI, but that didn't work. Finally, I ran accross this script that used ipconfig in PowerShell, then captured the IP address. I thought it threw before wasting time on yet another script, and figured it should work. Go figure, it did. Works great, and now I have a solution to my original issue of wanting just one task sequence for multiple time zones. Below is the new script.
location3.ps1 (the one that ended up working, stripped down version)
$IP = ((ipconfig |findstr [0-9].\.)[0]).split()[-1]
if ( $IP -like "10.15.20*")
{$local = "Columbus"}
else
{$temp = "NotColumbus"}
if ( $IP -like "10.15.36*")
{$local = "Phoenix"}
else
{$temp = "NotPhoenix"}
$tsenv = New-Object -COMObject Microsoft.SMS.TSEnvironment
$tsenv.Value("location") = "$local"
if ( $IP -like "10.15.20*")
{$local = "Columbus"}
else
{$temp = "NotColumbus"}
if ( $IP -like "10.15.36*")
{$local = "Phoenix"}
else
{$temp = "NotPhoenix"}
$tsenv = New-Object -COMObject Microsoft.SMS.TSEnvironment
$tsenv.Value("location") = "$local"
In case anyone was also wondering how I placed this in my task sequence, I shall show you.
Here is a screen shot of the top part of my task sequence.
The TS starts off with your normal restart the computer, and wipe the disc. When it comes to installing an OS, I'm installing an OS package, not an image. (Due to the wants/needs of the company) It installs the Windows XP SP3 package, applies Windows Settings and sets the time zone to Eastern Standard at that point. It then (skip a few tasks...) installs .NET 3.5, PowerShell v2, and applies PowerShells execution policy. It reboots to apply all the new shit I just did, then runs "Discover Location". At that point, it's running the above script. Then right below that you see two folders with tasks. This should be obvious, but I'll say it anyways... if the TS Variable produced by the script reads Arizona, then the Arizona folder runs and the Columbus folder is skipped. If the TS Variable produces Columbus, the Arizona folder is skipped and the Columbus folder is ran. Each folder has Task Sequence Variable conditions that make this happen. In case your imagination isn't going yet, you can use this same idea here to install different software based on a location as well. Pretty sweet.
On another topic, I found this sweet thing for iPhones. If you're running version 3.0 (and if you're running 3.1 you can always downgrade...) you can get tethering on your phone by going to "help.benm.at/help.php" on your phones browser. As long as you have an unlimited data plan (which I'm not sure if AT&T offers anything but that for the iPhone) you can then tether your iPhone to your computer via USB or Bluetooth for internet access.
Enjoy
