Active Directory 'Pager' field

This topic contains 7 replies, has 4 voices, and was last updated by  Anton Chernysh 2 years, 9 months ago.

  • Author
    Posts
  • #7329

    thickgit
    Participant

    We have an application that requires a unique number for each user to be entered into the user's 'Pager' field in AD.

    I'm using Import-Csv to create all of the users, but can't find a away of populating each user's 'Pager' field using either New-ADUser or Set-ADUser.

    Is this possible?

  • #7333

    Don Jones
    Keymaster

    Not directly, no – the commands don't directly wire up that attribute. You will have to pass it in a hashtable to the -Properties parameter instead

  • #7334

    thickgit
    Participant

    OK, before I posted, I tried something along the lines of:

    @{l='pager';e={'Unique-header-from-spreadsheet'}}

    You're right – it gave me a valid 'pager' value when I imported the CSV, but it didn't wire up to the AD account 'Pager' field.

    I didn't find any -Properties parameter in either of the cmdlets I listed above, but I did find an -OtherAttributes parameter.

    I've tried variations of:

    @{pager = {$_.'unique-header-from-spreadsheet'}

    I experimented moving the quotes around. The closest I got was a direct entry into the 'Pager' field, but it was just the phrase '$_.unique-header-from-spreadsheet' and not the relevant value.

    I'm close – any chance of another clue?!

  • #7354

    Art Beane
    Member

     All you need is a "simple" hash table; there's no need for a script block for the value field.

    @{pager = $_.’unique-header-from-spreadsheet’}
  • #7355

    Don Jones
    Keymaster

    Actually, the main problem is that the New-ADUser and Set-ADUser commands don't have a -Pager parameter. So you can't simply pipe in an object that has a Pager property – there's nowhere for it to go. You probably will need a different approach. Assuming a CSV file with a Name, samAccountName, and Pager column:

    Import-CSV file.csv | ForEach { New-ADUser -Name $_.Name -SamAccountName $_.samAccountName -OtherAttributes @{'Pager'=$_.Pager} }

  • #7543

    thickgit
    Participant

    Thanks to you both. Got it working.

    I think my way was too complicated. Don's was simpler than what I'd come up with so I copied his format.

    Cheers.

  • #8484

    thickgit
    Participant

    OK, just to follow on from that, I've exported a list of users whose 'Pager' field is empty. I've done a vlookup against a master spreadsheet to get the correct pager numbers for each user and ended up with a 2-column CSV file (Headers are 'SamAccountName' and 'Pager')

    You're right – 'Set-ADUser' doesn't have a 'Pager' parameter, and this time it doesn't have an '-OtherAttributes' parameter either.

    Meh.

    Thought I'd play with it before coming here asking for more hand-outs! Read the help for Set-ADUser and found the answer!

    Import-CSV C:\user_pagers.csv | ForEach-Object {Set-ADUser $_.SamAccountName -Replace @{Pager=$_.Pager}}

    Re-sult!

  • #22654

    Anton Chernysh
    Participant

    OK, just to follow on from that, I've exported a list of users whose 'Pager' field is empty. I've done a vlookup against a master spreadsheet to get the correct pager numbers for each user and ended up with a 2-column CSV file (Headers are 'SamAccountName' and 'Pager')

    You're right – 'Set-ADUser' doesn't have a 'Pager' parameter, and this time it doesn't have an '-OtherAttributes' parameter either.

    Meh.

    Thought I'd play with it before coming here asking for more hand-outs! Read the help for Set-ADUser and found the answer!

    Import-CSV C:\user_pagers.csv | ForEach-Object {Set-ADUser $_.SamAccountName -Replace @{Pager=$_.Pager}}

    Re-sult!

    For those who haven't tried this yet. I confirm it works.
    Thanks for your answer!

You must be logged in to reply to this topic.