Task Sequence Variable Organizational Unit
I have created a software install in my task sequence and for the task sequence variable i would like to specify the OU that the computer joined to in the previous step. The technicians add the workstations in Active Directory OU prior to the task sequence. What would this variable look like? Thanks!
September 13th, 2011 4:49pm

see below How can I use variables to join domain, set keyboard, regional options Using collection variables to set options My step by step SCCM Guides I'm on Twitter > ncbrady
Free Windows Admin Tool Kit Click here and download it now
September 13th, 2011 6:28pm

Thanks Niall as always you have been helpful. I looked into those variables but I did not find one that was to say "this workstation is in this OU, install software". Basically after the computer joins the domain it will be in the certain OU since we manually create them in AD. After that I would like to trigger the variable for one of my apps so I can seperate apps per sections of our business. ANy other ideas?
September 13th, 2011 7:17pm

Here is a script that will identify which OU the workstation is in and then create a file with the name of the OU. The next step will be to add this script as a software package, and create a variable with a "if" statement saying "if filename.txt is here install software. 1. This is the command to initiate the script (powershell required on workstation). powershell.exe .\FindMachineOU.ps1 ""%computername%""" 2. Actual script - param([string]$MachineName); # Create directory if does not exist if (Test-Path -path C:\OU) { # If directory does exist, remove all files Remove-Item C:\OU\* -recurse; } else { New-Item C:\OU -type directory; } #Create AD Directory Searcher $objADSearch = New-Object System.DirectoryServices.DirectorySearcher; #Build Filter to look for Machine $objADSearch.Filter = "(&(objectCategory=computer)(objectClass=computer)(name=$MachineName*))"; #Find Machine in AD $Results = $objADSearch.FindAll(); #OU Counter $OUCounts = 0; #If the machine is found If ($Results.Count -eq 1) { # Retrieve the AD Path $ADPath = $Results[0].Properties.adspath; # Split the AD Path by Comma $OUs = $ADPath[0].ToString().Split(","); # Loop through AD Paths for($i=0; $i -le $OUs.Count - 1; $i++) { # Retrieve the First Path $OU = $OUs[$i]; # If the Path is a Organization Unit if ($OU.StartsWith("OU")) { $OU = $OU.Replace("OU=",""); # Create Files New-Item C:\OU\$OU.txt -type file; # Increment OU Counter $OUCounts += 1; }; } if ($OUCounts -eq 0) { throw "Could not find any OUs for $MachineName."; } } else { throw "Could not find any OUs for $MachineName."; }
Free Windows Admin Tool Kit Click here and download it now
September 15th, 2011 2:53pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics