Jump to content


shadycat

Task Sequence Script to place devices in OU depending on name

Recommended Posts

Is it possible to query an IdentifyingNumber during a task sequence and use the result to place it in a particular OU in Active directory?

To return the asset tag i use the following query.

wmic:root\cli>csproduct get identifyingnumber
IdentifyingNumber
GXS045J

How can i use the result to place the machine in a particular OU in AD? 

Is this possible?

If it is how are people achieving this?

Many Thanks in advance.

Shadycat

Share this post


Link to post
Share on other sites

 

This script will take the IdentifyingNumber from the WMI and will change the TS value according to the Service Tag (IdentifyingNumber).

Read how to pace it in the Task sequence .

  

#===========

$Progress.CloseProgressDialog()
$TSEnv = New-Object -COMObject Microsoft.SMS.TSEnvironment


$tag = gwmi win32_computersystemproduct | select -ExpandProperty IdentifyingNumber


if ($Tag -like '*XX*') {$TSEnv.Value("OSDDomainOUName")='LDAP://OU=XXXXXX,DC=ecitele,DC=com'}
elseif ($Tag -like '*YY*') {$TSEnv.Value("OSDDomainOUName")='LDAP://OU=YYYYY,DC=ecitele,DC=com'}

 

#===============

Share this post


Link to post
Share on other sites

If the machine has never existed in AD before, then you can simply add multiple "Apply Network Settings" steps. Put a condition on each step so if computer name is GS111 the OU will be GS. If computer name is ES222 the OU will be ES etc etc.

Thats the easier method depending on how many OU's we are talking. The "scalable" way would using a vbscript to determine machine name and set the OSDDomainOUName variable which the task sequence can then action.

Share this post


Link to post
Share on other sites

Thanks for the help.

Looking at your responses it looks like i need to rename my workstations so the have RoomNumberAssetTAG so in my case it would be 1F001AssetTAG.  (Room Number = OU)

I work in an educational environment so we have computers by OU (Rooms) Room numbers 1F001, 1F002, 1F003.  Basically 20 computers in an OU and software gets deployed to the room based on the OU (or room) its in and its usually restricted to the number of PC's we can install software on by licensing.  

I have a list of Machine ID (Asset tags) against the OU they are supposed to be in.  Also we rename the PC using WMI queries to name the PC as its ID (Asset tag) during the OSD.  Using OSDComputerName and %SerialNumber%

Is there anyway i can place the machine based on its asset tag or computer name and place it in a container.

 

Many Thanks Shadycat

 

 

 

 

 

 

 

 

Share this post


Link to post
Share on other sites

Just to add to this is it could be possible to create multiple "apply network settings" so in my case in a task sequence

apply network settings 1F001

apply network settings 1F002

apply network settings 1F003

How could i use conditions so that if a Machine ID (Asset tag) is one of the following

AssetTag1

AssetTag2 

AssetTag3

It is put in OU 1F001 as per the settings specified in apply network settings 1F001 (Join Domain and Domain OU)

 

 

Many Thanks ShadyCat

 

 

network1.png

network2.png

Share this post


Link to post
Share on other sites

Just an update, I am looking at these conditions but it means i would have to create a wmi query for every workstation we have (about 1200)

network3.png.7ed58c901fd2e872b691c352545030eb.png

 

Is there anyway i can achieve this by referencing a csv file?

Or is there anyway to edit the conditions using copy and paste for example?

Many Thanks Shadycat

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...


×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.