Set-ADUser script to update Initials

This topic contains 0 replies, has 1 voice, and was last updated by Profile photo of Forums Archives Forums Archives 5 years, 5 months ago.

  • Author
    Posts
  • #5658

    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]}

You must be logged in to reply to this topic.