< Back

Get-OldADUsers

Fri Jan 10, 2020 7:05 pm

NAME Get-OldADUsers



SYNOPSIS

Get users that haven't logged in for the specified time.





SYNTAX

Get-OldADUsers [-DaysOld] <Int32> [[-SearchBase] <String>] [[-Domain] <String>] [-Credential <PSCredential>]

[<CommonParameters>]





DESCRIPTION

The cmdlet finds all users that haven't logged in for the specified time. It first looks for the

msDS-LastSuccessfulInteractiveLogon if that has been enabled in the domain. If it is not present, it uses the

LastLogonTimeStamp.





PARAMETERS

-DaysOld <Int32>



Required? true

Position? 1

Default value 0

Accept pipeline input? true (ByValue)

Accept wildcard characters? false



-SearchBase <String>

The DistinguishedName of the OU path to search under. This defaults to the root of the domain.



Required? false

Position? 2

Default value [System.String]::Empty

Accept pipeline input? false

Accept wildcard characters? false



-Domain <String>

The domain to search in.



Required? false

Position? 3

Default value [System.String]::Empty

Accept pipeline input? false

Accept wildcard characters? false



-Credential <PSCredential>

Specifies a user account that has permission to perform this action. The default is the current user.



Type a user name, such as "User01" or "Domain01\\User01", or enter a PSCredential object, such as one generated

by the Get-Credential cmdlet. If you type a user name, you will be prompted for a password.



Required? false

Position? named

Default value [System.Management.Automation.PSCredential]::Empty

Accept pipeline input? false

Accept wildcard characters? false



<CommonParameters>

This cmdlet supports the common parameters: Verbose, Debug,

ErrorAction, ErrorVariable, WarningAction, WarningVariable,

OutBuffer, PipelineVariable, and OutVariable. For more information, see

about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).



INPUTS

System.Int32





OUTPUTS

System.Management.Automation.PSObject[]





NOTES





AUTHOR: Michael Haken

LAST UPDATE: 1/7/2017



-------------------------- EXAMPLE 1 --------------------------



PS C:\\>Get-OldUsers -DaysOld 60



Gets all users that haven't logged on in at least 60 days.









-------------------------- EXAMPLE 2 --------------------------



PS C:\\>Get-OldUsers -DaysOld 60 -SearchBase "OU=Finance,OU=HQ,DC=contoso,DC=com"



Gets all users in the Finance OU and child OUs that haven't logged on in at least 60 days.











RELATED LINKS