none
Script to change -manager attribute in AD RRS feed

  • Question

  • I am trying to put together a script that takes a csv from our HR system and updates attributed in AD. I have been using syntax like this for other attributes with no issues:

    Import-Csv $Importedcsv | ForEach-Object {
    Set-QADUser $_.mail -manager $_.Supervisor_Primary `
    -ObjectAttributes @{ExtensionAttribute1=($_.ExtensionAttribute1);
    ExtensionAttribute2=($_.ExtensionAttribute2)}
    }
    

    I have a csv from HR that has the following format:

    The issue that we are running into is that the attributes that are coming from our HR systems do not coincide with anything we have in AD. How do we populate the -manager attribute using data from this csv?

    Thanks for everyone's help!

    Brian

    Monday, August 24, 2015 7:26 PM

Answers

  • Mike's suggestion might work if you have a small number of potential supervisors, their names match the exact attributes set in AD, and there are no duplicates (those are three potential problems I can think of off the top of my head).

    A more robust solution is to create a lookup list that contains the Supervisor_Primary list from your HR system and the corresponding sAMAccountName of the matching AD account, and use that to assign the manager attribute instead.


    -- Bill Stewart [Bill_Stewart]

    Monday, August 24, 2015 9:49 PM
    Moderator

All replies

  • Hi Brian,

    You might be able to split the data in that cell and then use a filter like so:

    Import-Csv .\input.csv | ForEach {
    
        $mgr = $_.Supervisor_Primary -split ','
    
        Get-ADUser -Filter "GivenName -eq '$($mgr[1])' -and Surname -eq '$($mgr[0])'"
    
    }


    Monday, August 24, 2015 7:34 PM
  • Mike's suggestion might work if you have a small number of potential supervisors, their names match the exact attributes set in AD, and there are no duplicates (those are three potential problems I can think of off the top of my head).

    A more robust solution is to create a lookup list that contains the Supervisor_Primary list from your HR system and the corresponding sAMAccountName of the matching AD account, and use that to assign the manager attribute instead.


    -- Bill Stewart [Bill_Stewart]

    Monday, August 24, 2015 9:49 PM
    Moderator
  • Thanks for both of your posts. We already have two people who have the same last name and first initials so I am unsure that Mike's recommendation will work.

    I will start looking at how to build a lookup list.

    Thanks

    Brian

    Monday, August 24, 2015 10:00 PM