none
Using Get-ADUser but 3.0 needs a filter? What changed? RRS feed

  • Question

  • I'm trying to just do a basic query of AD attributes from a text file of SamAccountNames I have, but I'm upgraded to PowerShell ISE 3.0 and there might be some things new I'm not understanding. 

    I was just trying to do something simple like this; Get-Content C:\Scripts\userabrivs.txt | ForEach { Get-ADUser -Properties * } | Export-csv C:\scripts\Output\adusers1 

    but in ISE it always asks for 

    cmdlet Get-ADUser at command pipeline position 1
    Supply values for the following parameters:
    (Type !? for Help.)
    Filter: 

    I'm not very good at this so can someone help me understand why it needs a filter when I'm just asking it to use the list of SamAccountNames I have in a text file?

    Tuesday, March 18, 2014 8:38 PM

Answers

All replies

  • Hi,

    You're never telling Get-ADUser which user you want to return. Try this instead:

    Get-Content .\userList.txt | ForEach {
    
        Get-ADUser -Identity $_ -Properties *
    
    } | Export-Csv .\userProperties.csv

    I highly recommend only returning the properties you need, the wildcard will return more information than most people want to look at.


    Don't retire TechNet! - (Don't give up yet - 12,700+ strong and growing)

    • Marked as answer by MarcGel Tuesday, March 18, 2014 10:43 PM
    Tuesday, March 18, 2014 8:47 PM
  • Get-AdUser works the way it has always worked in CLI or ISE.

    Get-AdUser - returns error.

    Get-AdUser (identity) - returns one user

    Get-AdUser -Filter * - returns all users.

    It works this way in all versions of PowerShell.


    ¯\_(ツ)_/¯

    Tuesday, March 18, 2014 8:55 PM