This script will query the event viewer logs of a specified system for a list of logon times for a specific user. There are four fields in the report: Keyboard logons, Screen Unlock, Remote Session logons, and Cached Logon. It has the option to either generate a report in a CSV file with all of the above field data, or it can generate a TXT file containing the raw message data with each data field split off by two dash rows.
NOTE: This does not require WinRM to be enabled to run on external systems. Also, this can take quite a while to execute if the logs are really big.
.PARAMETERComputerName
Name of system to retrieve the logs from. If this is left blank, the script will use "." representing the computer this script is executing on.
.PARAMETERRawdata
Generate a report using the raw data from the event viewer logs of the specified user
.PARAMETERUsername
Username to generate this report of.
.EXAMPLE
Generate a CSV file report containing the times and sorted by each logon type
This script will retrieve the SID by querying the HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList by matching the ProfileImagePath value with the Username parameter.
.EXAMPLE
PS C:\> Get-SID
.NOTES
Additional information about the function.
#>
[CmdletBinding()][OutputType([string])]
param ()
Write-Host"Retrieving SID for $Username....."-NoNewline