Link to home
Start Free TrialLog in
Avatar of Indie101
Indie101

asked on

Script for last modification date for AD accounts

Looking for a powershell script that satisifies getting

Last modification date for AD accounts in an organistation

Want to use it to check AD accounts that haven't been modified in over a year

Have used lastlogon and lastlogontimestamp but looking for modification
Avatar of oBdA
oBdA

Like that, for example:
$date = (Get-Date).AddDays(-365)
get-aduser -Filter {modifyTimeStamp -lt $date} -Property modifyTimeStamp | Select SamAccountName, ModifyTimeStamp, DistinguishedName |
	Export-Csv -NoTypeInformation -Path C:\Temp\modified.csv

Open in new window

Avatar of Indie101

ASKER

Thanks for that get the below 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.
At line:1 char:36
+ $date = (Get-Date).AddDays(-365) | get-aduser -Filter {modifyTimeStamp -lt $date ...
+                                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (16/11/2017 14:22:14:DateTime) [Get-ADUser], ParameterBindingException
    + FullyQualifiedErrorId : InputObjectNotBound,Microsoft.ActiveDirectory.Management.Commands.GetADUser
ASKER CERTIFIED SOLUTION
Avatar of oBdA
oBdA

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Sure point take taken :) I couldnt fit the lines in originally

Thanks
Thanks very much that did the job really well :)