On a Customer I have a special challenge during a OSD-Tasksequence.
The Challenge was to read the OSDComputername before the OS can be installed, to select the right Image (WIM) to install on a Client.
First we implemented the OSD WebPortal to create the Computer-Object with MAC-Address
In the TS we would like to read the computer name the first two Digits to create another variable to execute the right step. The right step means the right OS for like a Slim or FAT OS installation on different Hardware.
Slim is just a OS installation with a Program like Citrix Receiver and the right links to the Farm.
FAT is a full OS installation with Office and some other Packages and Applications.
What we do, we use PowerShell of Corse (in this case a big Thank you to my Friend Thomas Kurth, he helps me after my Blackout in running the wrong Script )
OK, here are the step by step I used to the solution:
1. in the Boot Image I add the PowerShell Module
Run the Wizard finish and Update the Distributionpoints.
2. After that we create the Script;
First we load the right Environment Variables
$tsenv = New-Object -COMObject Microsoft.SMS.TSEnvironment
then we use the Variable “_SMSTSMachineName”
with a IF and else query we set our own OS TS Variable to use it during the TS
if($tsenv.Value("_SMSTSMachineName") -match "SC"){ $tsenv.Value("OS") = "SC" } elseif($tsenv.Value("_SMSTSMachineName") -match "PC"){ $tsenv.Value("OS") = "PC" }elseif($tsenv.Value("_SMSTSMachineName") -match "NB"){ $tsenv.Value("OS") = "NB" } else { exit 99999 }
We save the Script on our Content source Folder (maybe we create a new folder) and then we start to create a Package without a Program.
3.
Distribute the Package to DP
4. Create a TS Step “Run Command line”
powershell.exe -ExecutionPolicy Bypass -file getNametoVariable.ps1
5. After this steps you can Use the Variable OS
Finish, now you can use this Variable during the whole TS maybe to install SW or the Right Driver stuff.
Hope it helps, please test it in your Test-Environment, the script is as is, no guarantee
/Mirko
Leave a Reply