SCCM OSD Computer Name – PowerShell Script

I always use a HTA (UI++) for my SCCM Task Sequences to fill a lot of variables at the start of the sequence, however i was recently asked to make a Zero Touch (ZTI) build for Windows 10 for a specific department. This is a pretty simple request however the main hurdle was dynamically setting part of the computer name as we use Location-Serial.

In this case im lucky as the Location is fixed, its just the serial i need to worry about.

Here is a simple PoSH script to set your PC name to FIXEDVALUE-Serial (last 7 digits)


<#
.NOTES
===========================================================================
Created on: 22/04/2016 16:27
Created by: dpadgett
Organization: –
Filename: ZTi.ps1
===========================================================================
.DESCRIPTION
Names PC during SCCM OSD With Fixed Value (HAIG) + Serial from WMI (Truncated) (LOC = Location)
#>
$Serial = Get-WmiObject Query 'select IdentifyingNumber from Win32_ComputerSystemProduct' Namespace 'Root\cimv2'
$Model = Get-WmiObject Query 'select Name from Win32_ComputerSystemProduct' Namespace 'Root\cimv2'
$SerialNo = $Serial.IdentifyingNumber.SubString(3)
$TS = New-Object ComObject "Microsoft.SMS.TSEnvironment"
$TS.Value("OSDComputername") = 'LOC-' + $SerialNo
## Example Locatio would be LOC-54477X4
$TS.Value("XModel") = $Model.Name

view raw

ztiname.ps1

hosted with ❤ by GitHub

All you need to do now is add this PS1 to your scripts folder, and create a step at the start of your Task Sequence.

Cheers,
Dan
Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s