I’m trying to build an script where I need 2 variables to come together and make a new variable (word). Our users in our AD are based on a policy. The firstname and lastname. we take the first 5 characters of the lastname and the first 2 characters from their firstname.
My fullname is Damian Eickhoff, my username is Eickhda. Now I created a small input form where I can enter the Firtsname and Lastname as 2 individual variables but I can’t find out how I can glue those together based on our policy.
$fn = read-host -Prompt "Firstname" $ln = read-host -Prompt "Lastname" $org = read-host -Prompt "Organization" $orgc = read-host -Prompt "Organization code" $user = $fn.split[-5] $User | Add-Member –MemberType NoteProperty -Name ChangePasswordAtLogon -Value $true $User | Add-Member –MemberType NoteProperty -Name HomeDirectory -Value "\\Server\Home\$($orgc.cc)\$($user.SamAccountName)" $User | Add-Member –MemberType NoteProperty -Name HomeDrive -Value "L:" $user | Add-Member –MemberType NoteProperty -Name UserPrincipalName -Value "$($user.SamAccountName)@$org.nl"