Created
November 29, 2021 18:17
-
-
Save ffcommax/a1ccb72af36631bcea751e95ee4710ac to your computer and use it in GitHub Desktop.
rdphistory
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$LogName = 'Microsoft-Windows-TerminalServices-LocalSessionManager/Operational' | |
$Results = @() | |
$Events = Get-WinEvent -LogName $LogName | |
foreach ($Event in $Events) { | |
$EventXml = [xml]$Event.ToXML() | |
$ResultHash = @{ | |
Time = $Event.TimeCreated.ToString() | |
'Event ID' = $Event.Id | |
'Desc' = ($Event.Message -split "`n")[0] | |
Username = $EventXml.Event.UserData.EventXML.User | |
'Source IP' = $EventXml.Event.UserData.EventXML.Address | |
'Details' = $Event.Message | |
} | |
$Results += (New-Object PSObject -Property $ResultHash) | |
} | |
$Results | Export-Csv 'Remote Desktop Users.csv' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment