Author Posts

January 1, 2012 at 12:00 am

by Alfa166 at 2013-03-13 04:35:35

Hello,

I am quite new to Powershell, infact waiting to get on a Course in the near future, sooner the better!

In the meantime I have a requirement to update all our AD Users accounts middle Initial with the first letter of their first name.
So Joe Bloggs would have their middle initial updated as Joe J Bloggs.

It look to me as is Set-ADUser would be the command to use but I am having little success at the moment.

Any help with the Syntax to achieve the above would be gratefully appreciated.

Thanks

Alfie

by bgenwell at 2013-03-13 05:12:02

This will work. You can limit it based on search filters, to do more of the work on the DC end and limit the amount of data that's passed over the network, but as it stands this will update every account.

import-module activedirectory

get-aduser -filter * | %{set-aduser -identity $_ -initials $_.givenname[0]}