Export-LastLogonTime

1.6.3

Export-LastLogonTime takes the OU name or distinguished name specified in the OU parameter and retrieves its users' account names and last logon times.  Then it exports a CSV file to the destination given in the Path parameter. This command will search the entire domain for the OU name specified.  If the destination path contains spaces it must be wrapped in quotation
Export-LastLogonTime takes the OU name or distinguished name specified in the OU parameter and retrieves its users' account names and last logon times.  Then it exports a CSV file to the destination given in the Path parameter. This command will search the entire domain for the OU name specified.  If the destination path contains spaces it must be wrapped in quotation marks, and the file name specified must end in .csv.

Due to the fact that the LastLogonDate does not replicate between domain controllers, this script will search for domain controllers and compare the LastLogonDate from each one to find the most recent time a user logged. This will be the time reported in the CSV file, and a column named DomainController will contain the Domain Controller the time came from unless specific Domain Controllers are specified to the Server parameter.

While available, supplying specific Domain Controllers to the Server parameter is discouraged because there is a possibility they will not be correct due to the reason described above.

The Property and SortBy parameters can be used to specify what properties will be exported to the CSV file, and how the users are sorted, but the properties LastLogonDate and DomainController will always be present.

Show more

Installation Options

Copy and Paste the following command to install this package using PowerShellGet More Info

Install-Script -Name Export-LastLogonTime -RequiredVersion 1.6.3

Copy and Paste the following command to install this package using Microsoft.PowerShell.PSResourceGet More Info

You can deploy this package directly to Azure Automation. Note that deploying packages with dependencies will deploy all the dependencies to Azure Automation. Learn More

Manually download the .nupkg file to your system's default download location. Note that the file won't be unpacked, and won't include any dependencies. Learn More

Owners

Copyright

©2013-2017 Chris Carter

Package Details

Author(s)

  • Chris Carter

Tags

ActiveDirectory LastLogonTime LastLogonDate

Functions

Test-Module Get-LogonTimes

Dependencies

This script has no dependencies.

Release Notes

Most importantly, the Destination parameter was renamed to the Path parameter to bring it inline with other Export-* commands, but Destination can still be used as an alias to avoid breaking older code. Also, the Property, SortBy, and Descending parameters were added. The Property parameter is used to choose which properties are exported to the CSV file. The SortBy parameter was added due to a user request over at the PowerShell Gallery, and is used to specify which columns to sort on when exporting the objects. The Descending parameter is used to sort the objects into descending order. Due to the addition of the new parameters, the default output has been changed, and the DisplayName property is no longer included in the default output. This update also contains a fix for a bug that occurred when running the command against only one Domain Controller. This was happening because a one item array was incorrectly being converted into the item itself.

FileList

Version History

Version Downloads Last updated
1.6.4 794 11/28/2018
1.6.3 (current version) 480 6/27/2017
1.5 255 6/16/2016
1.4 72 4/14/2016
1.3.1 26 4/5/2016
1.2 35 3/7/2016
Show more