The challenge was to move the Computers in the correct OU. The Computer naming convention are: XXX000 (3 Letters for City Code, 3 enumerating digits).
So the PS Script identifies the OU of the first 3 characters. The LDAP String is hardcoded for the selected OU and is set as TS Variable "OSDJoinDomainOUName"
So this is the PowerShell Script,
$myComputername = $env:computername
$myComputernameShort = $myComputername.Substring(0,3)
switch ($myComputernameShort)
{
"FRA" {$LDAPValue = "LDAP://OU=Computers,OU=Frankfurt,DC=company,DC=de"}
"BER" {$LDAPValue = "LDAP://OU=Computers,OU=Berlin,DC=company,DC=de"}
"HAM" {$LDAPValue = "LDAP://OU=Computers,OU=Hamburg,DC=company,DC=de"}
default {$LDAPValue = ""}
}
$tsenv = New-Object -COMObject Microsoft.SMS.TSEnvironment
$tsenv.Value("OSDJoinDomainOUName") = $LDAPValue
With this TS Variable, you can now set the OU to this Varialbe. And your Clients join in the given OU!
Hope this will help you!