none
Find user in AD by pager info into a variable RRS feed

  • Question

  • Hi guys, I have a problem. We need to do a script to find user with pager number from a variable, we have this lines but it dosent work. Can you help me?.

     

    $FileListOfUsers = "C:\Scripts\Bajas\dni.csv"
     
    $ListOfDNI = Get-Content $FileListOfUsers
    
    
    $ListOfDNI | Get-ADUser -Filter * -Properties * | 
    Where-Object {$_.pager -ne $null} |
    Export-Csv c:\Scripts\list.csv
     
    The content of $ListOfDNI are:
    
    12345678A
    12345678B
    12345678C
    12345678D


     


    • Edited by Ibellidom Tuesday, June 26, 2018 8:28 AM code posting tool
    • Moved by Bill_Stewart Tuesday, July 31, 2018 3:05 PM Unanswerable drive-by question
    Tuesday, June 26, 2018 8:10 AM

All replies

  • Please do not post colorized code.  Please take the time to learn how to post correctly in this forum.  Use the code posting tool provided.


    \_(ツ)_/

    Tuesday, June 26, 2018 8:11 AM
  • What does not work? Do you get any error messages? If yes please post them as text.
    Tuesday, June 26, 2018 8:13 AM
  • Upsss sorry, corrected
    Tuesday, June 26, 2018 8:29 AM
  • What are the numbers?  Are they user account names?

    What are the errors?  You fail to say what you problem is.


    \_(ツ)_/

    Tuesday, June 26, 2018 8:32 AM
  • That is the error:

    Get-ADUser : The input object cannot be bound to any parameters for the command either because the command does not take pipeline input or the input and its properties do not match any of the parameters that take pipeline input

    Tuesday, June 26, 2018 8:33 AM
  • Get-Content C:\Scripts\Bajas\dni.csv |
        Get-ADUser -Filter  {Pager -ne $null} -Properties pager | 
        Export-Csv c:\Scripts\list.csv
     


    \_(ツ)_/

    Tuesday, June 26, 2018 8:36 AM
  • The numbers are the human resources internal codification, all have 8 digits and a letter.
    The objetive is, with  the pager number, do a search in AD and disable the user that meets the requirements. We have todo it for a list of users (numbers).

    Tuesday, June 26, 2018 8:37 AM
  • That That cannot be used with AD if it is not a field in AD.

    Please take some time to learn AD before trying to guess at how to use it.


    \_(ツ)_/

    Tuesday, June 26, 2018 8:40 AM
  • Pager its a field in AD, Its under telephone options.
    Tuesday, June 26, 2018 8:45 AM
  • The list of numbers is what I am referring to.  This is why you need to learn AD.  You need to understand it so you can understand the answers.

    The numbers provided cannot be used to find users in AD.


    \_(ツ)_/

    Tuesday, June 26, 2018 8:49 AM
  • Get-ADUser cannot find an AD user for at least one of your given usernames (samaccountname?).

    You rewrite your script to use try/catch to deal with this error message or use the example jrv provided getting all users with the pager attribute value $null and then compare it with your user input list to only work with the users you want.

    Tuesday, June 26, 2018 9:11 AM
  • Get-ADUser cannot find an AD user for at least one of your given usernames (samaccountname?).

    You rewrite your script to use try/catch to deal with this error message or use the example jrv provided getting all users with the pager attribute value $null and then compare it with your user input list to only work with the users you want.

    None  of this will work because the numbers are not user IDs.  The OP needs to learn a bit about how to use and search AD and provide a list of user IDs or other account identifiers.

    Let's not go in circles.


    \_(ツ)_/

    Tuesday, June 26, 2018 9:15 AM
  • None  of this will work because the numbers are not user IDs.  The OP needs to learn a bit about how to use and search AD and provide a list of user IDs or other account identifiers.

    As long as the op does not say if the numbers (with a letter at the end) are real usernames or not, we both can only guess.

    I've seen such usernames (samaccountnames) before.

    Tuesday, June 26, 2018 9:19 AM
  • None  of this will work because the numbers are not user IDs.  The OP needs to learn a bit about how to use and search AD and provide a list of user IDs or other account identifiers.

    As long as the op does not say if the numbers (with a letter at the end) are real usernames or not, we both can only guess.

    I've seen such usernames (samaccountnames) before.

    He answered that.  They are not.


    \_(ツ)_/

    Tuesday, June 26, 2018 9:28 AM
  • It is very difficult to understand what you want to achieve here. Are you trying to say that each number from your csv corresponds to the pager attribute of a user account?

    Tuesday, June 26, 2018 6:07 PM