none
Getting an error when running a Power Shell script RRS feed

  • Question

  • When running the below, I get in red letters  "Get-ADComputer : The size limit for this request was exceeded."  I don't know the why or how to get around this error.

    Get-ADComputer -Filter * -Properties *

      | Sort LastLogonDate | FT Name, LastLogonDate -Autosize | Out-File C:\Temp\ComputerLastLogonDate.txt


    Francisco Mercado Jr.

    Tuesday, January 17, 2017 2:46 PM

Answers

  • Hi Francisco,

    that's because you are asking for too much (and angering the PowerShell god ;) ). Too much information, that is.

    Get-ADComputer -Filter * -Properties LastLogonDate | Sort LastLogonDate | Export-Csv C:\Temp\ComputerLastLogonDate.csv

    This only requests the information that you use and creates csv file that Excel can read. Neat, right?

    Cheers,
    Fred


    There's no place like 127.0.0.1

    Tuesday, January 17, 2017 2:54 PM
  • You can set -resultsize parameter to $null to receive all objects. Also i would suggest to limit number of computer using searchbase parameter or selecting required properties only instead of using -properties *.
    • Marked as answer by dvua Thursday, January 26, 2017 1:07 AM
    Wednesday, January 18, 2017 6:28 AM

All replies

  • Hi Francisco,

    that's because you are asking for too much (and angering the PowerShell god ;) ). Too much information, that is.

    Get-ADComputer -Filter * -Properties LastLogonDate | Sort LastLogonDate | Export-Csv C:\Temp\ComputerLastLogonDate.csv

    This only requests the information that you use and creates csv file that Excel can read. Neat, right?

    Cheers,
    Fred


    There's no place like 127.0.0.1

    Tuesday, January 17, 2017 2:54 PM
  • If you really want a text report then:

    Get-ADComputer -Filter * -Properties LastLogonDate |
    	Sort LastLogonDate | 
    	FT Name, LastLogonDate -Autosize | 
    	Out-File C:\Temp\ComputerLastLogonDate.txt
    
    


    \_(ツ)_/

    Tuesday, January 17, 2017 3:37 PM
  • Using -Filter * is probably necessary if you want info on all computers, but I avoid using -Properties * because it retrieves most properties/attributes that have values. This is especially true with -Filter *, which will result in a huge recordset that must communicate over the network (most likely) from a DC to the client. In this case you only select Name and LastLogonDate. Name is a default properity of Get-ADComputer that is always retrieved. But LastLogonDate is an extended property so you must request it with the -Properties parameter.


    Richard Mueller - MVP Enterprise Mobility (Identity and Access)

    Tuesday, January 17, 2017 4:03 PM
    Moderator
  • You can set -resultsize parameter to $null to receive all objects. Also i would suggest to limit number of computer using searchbase parameter or selecting required properties only instead of using -properties *.
    • Marked as answer by dvua Thursday, January 26, 2017 1:07 AM
    Wednesday, January 18, 2017 6:28 AM