gumbygaz Posted November 18, 2015 Posted November 18, 2015 Afternoon, We've got GADs synchronising all the staff and students and all is well, however, the teachers account all display their Full names so when sharing/emailing with the Students their full names are displayed. Which for a number of staff they find annoying, which I can understand, is there an easy way to change the givenname attribute to only show the 1st character of their first name? Some clever trim function (here's hoping!)? I know I can blank it, so will ultimately do that show it'll just show surname but it would like tidier. Just seeing if there's something I can do with ADModify but wanted to avoid altering the AD if possible, any ideas? Cheers
ticker Posted November 18, 2015 Posted November 18, 2015 Hi @gumbygaz, i have just had to do this exact same thing at my school due to several members of staff unhappy their given name was displayed in the contacts list that students could see. They way i have done it is to make sure in AD that in the initials field it has the staff's initial then in GADS the given name attribute I have changed to initials. Re-run the sync tool and works a treat. Still amazes me despite my ten plus years in education what I would say is a small thing what staff get hung up about. 1
gumbygaz Posted November 19, 2015 Author Posted November 19, 2015 Perfect! Not sure how I missed that, was so obvious my brain must have blanked that option out! Thanks Still need to populate the initial field but should be able to sort that out easily enough. Thanks!
gumbygaz Posted November 20, 2015 Author Posted November 20, 2015 @ticker Done a test sync, looks like thats going to work. Just it's going to change the students too, which I guess I would prefer them to be full first & second name, however, I don't think you can separate them without have two xml configs? I'm assuming you did the same for the Students also? I don't think it's really a problem I suppose, making problems for myself!
ticker Posted November 20, 2015 Posted November 20, 2015 @gumbygaz, i only populated the staff AD accounts with initials not students (i left these blank). So when I ran the test sync it reported that it had modified the staffs given name but just left the students names as they were. 1
gumbygaz Posted November 23, 2015 Author Posted November 23, 2015 You're indeed right, again! Looked at the test sync and the first couple returned were student accounts so thought they were all changing... but just a couple anomalies. Staff all changed, marvellous! thanks again.
Valyyn Posted November 24, 2015 Posted November 24, 2015 If it helps, we use extendedAttribute2 for the first name in GADS, which is set to the actual firstname for students but the first letter of the firstname for staff. (extendedAttribute1 is the "mail" value for GADS). I run a PS script when we add a new user which sets up the values for us before we GADS sync (although if it's just one new user, doing it manually is probably quicker). 1
gumbygaz Posted November 25, 2015 Author Posted November 25, 2015 Might look at doing something like that, I think it looks better with the Students first name in there. Haven't added a new Student since the initial attribute change but if any issues i'll look at implementing the extendedattribute idea. Thanks
Valyyn Posted November 25, 2015 Posted November 25, 2015 No worries! If you want the PS scripts to help or anything, just shout
TronXP Posted November 25, 2015 Posted November 25, 2015 To jump on the bandwagon, it would be nice to see the PS script to do this.
Valyyn Posted November 25, 2015 Posted November 25, 2015 This is our student one. When we make a new student, we set their mail field to their gmail email address. The below script goes through every user in the OU specified (including sub-OUs) and: Changes the extendedAttribute1 to be their email address Changes extendedAttribute2 to their first name $path = "[color="#FF0000"][b][PATH_TO_LOG_FILE][/b][/color]\students.log" $users = get-aduser -searchbase '[b][color="#FF0000"]OU=Students,OU=[OU],DC=[domain_controller],DC=local[/color][/b]' -filter * $LogString = 'Starting full sync at {0} on {1}'-f (Get-Date).ToString("hh:mm:ss"),(Get-Date).ToString("dd/MM/yyyy") add-content -Path $path -Value $LogString -Force $LogString = '---------------------------------------------------------------' add-content -Path $path -Value $LogString -Force foreach ($user in $users){ $username = get-aduser $user.samaccountname -prop name|select -expand name $givenname = get-aduser $user.samaccountname -prop givenname|select -expand givenname $mail = get-aduser $user.samaccountname -prop mail|select mail if($mail -match "@[b][color="#FF0000"][Gmail_domain][/color][/b].com"){ $newAttribute1 = get-aduser $user.samaccountname -prop mail|select -expand mail $LogString = 'Name:'+$username add-content -Path $path -Value $LogString -Force $LogString = 'Current email:'+ $newAttribute1 add-content -Path $path -Value $LogString -Force Set-ADUser -Identity $user.samaccountname -replace @{"extensionattribute1"="$newAttribute1"} $extensionAttribute1 = get-aduser $user.samaccountname -prop extensionAttribute1|select -expand extensionAttribute1 $LogString = 'New extensionAttribute1:'+$extensionAttribute1 add-content -Path $path -Value $LogString -Force $LogString = '---------------------------------------------------------------' add-content -Path $path -Value $LogString -Force } Set-ADUser -Identity $user.samaccountname -replace @{"extensionattribute2"="$givenname"} } $LogString = 'Finished sync at {0} on {1}'-f (Get-Date).ToString("hh:mm:ss"),(Get-Date).ToString("dd/MM/yyyy") add-content -Path $path -Value $LogString -Force $LogString = '' add-content -Path $path -Value $LogString -Force $LogString = '***********************************************************************************************************************' add-content -Path $path -Value $LogString -Force For the staff one, the first name/extendedAttribute2 line is replaced with: Set-ADUser -Identity $user.samaccountname -replace @{"extensionattribute2"="$givenname".substring(0,1)} which just takes the first letter of their first name. Actually, I'll post the whole staff ps1 file, as it's got one other difference - staff emails are on our Exchange server, so their mail attribute has a different domain to our Google domain. This script takes their mail address, switches the domain to the google domain and then saves it to extendedAttribute1: $path = "[color="#FF0000"][b][PATH_TO_LOG_FILE][/b][/color]\staff.log" $users = get-aduser -searchbase '[b][color="#FF0000"]OU=Staff,OU=[OU],DC=[domain_controller],DC=local[/color][/b]' -filter * $LogString = 'Starting full sync at {0} on {1}'-f (Get-Date).ToString("hh:mm:ss"),(Get-Date).ToString("dd/MM/yyyy") add-content -Path $path -Value $LogString -Force $LogString = '---------------------------------------------------------------' add-content -Path $path -Value $LogString -Force foreach ($user in $users){ $username = get-aduser $user.samaccountname -prop name|select -expand name $givenname = get-aduser $user.samaccountname -prop givenname|select -expand givenname $mail = get-aduser $user.samaccountname -prop mail|select mail if($mail -match "@[color="#FF0000"][b][email_domain][/b][/color].co.uk"){ $mailusername = get-aduser $user.samaccountname -prop mail|select -expand mail $newAttribute1 = $mailusername -Replace "@[color="#FF0000"][b][email_domain][/b][/color].co.uk","@[color="#FF0000"][b][Gmail_domain][/b][/color].com" $LogString = 'Name:'+$username add-content -Path $path -Value $LogString -Force $LogString = 'Current email:'+ $mailusername add-content -Path $path -Value $LogString -Force Set-ADUser -Identity $user.samaccountname -replace @{"extensionattribute1"=$newAttribute1} $extensionAttribute1 = get-aduser $user.samaccountname -prop extensionAttribute1|select -expand extensionAttribute1 $LogString = 'New extensionAttribute1:'+$extensionAttribute1 add-content -Path $path -Value $LogString -Force $LogString = '---------------------------------------------------------------' add-content -Path $path -Value $LogString -Force } Set-ADUser -Identity $user.samaccountname -replace @{"extensionattribute2"="$givenname".substring(0,1)} } $LogString = 'Finished sync at {0} on {1}'-f (Get-Date).ToString("hh:mm:ss"),(Get-Date).ToString("dd/MM/yyyy") add-content -Path $path -Value $LogString -Force $LogString = '' add-content -Path $path -Value $LogString -Force $LogString = '***********************************************************************************************************************' add-content -Path $path -Value $LogString -Force 1
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now