Inputs: StaleDays - A threshold for the # of days to use to mark accounts stale. The default is 90.
Minimum ITScripts engine version required: 188.8.131.52
Modifies the target machine: No
Name: Get Remote Users Last Login Times
Purpose: Get last login times for users on a remote system
Script Version: 184.108.40.206
Target Type: Any
This script gets the local accounts from a target machine and the last login for each account.
The script connects to the target machine using WMI and gets the target machine OS. If the connection fails a WMI error is given for the machine.
The script then uses WMI to get all local accounts that are not locked out. Then for all other local accounts it determines the last login date.
The script then determines the age in days of the last login. If the age is greater than or equal to the StaleDays parameter it is marked its status as stale.
If the account has never logged in the status is set to “Has never logged in”.
Output results to csv:
ComputerName, Username, Lastlogin dateTime, Age in Days, Status
The possible Opsmon output options are:
"WMI connection to the target machine failed. The machine may be offline or firewalled"
ComputerName, UserName, Last Login, Age, Status
"Failed to get WMI access to account information"