Last active
August 12, 2019 08:55
-
-
Save kmhuglen/b52d0afb59901dd0d7f1ab44d54442ee to your computer and use it in GitHub Desktop.
RDS: Find out who, when and from where users logon/logoff
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
$allRDPevents = Get-WinEvent -FilterHashtable @{Logname = "Microsoft-Windows-TerminalServices-RemoteConnectionManager/Operational" ; ID = 1149,1150,1148} -ErrorAction SilentlyContinue | |
$RDPevents = @() | |
foreach ($event in $allRDPevents) | |
{ | |
$result = $null | |
switch ($event.ID) | |
{ | |
1148 { $result = "failed" } | |
1149 { $result = "succeeded" } | |
1150 { $result = "merged" } | |
} | |
$RDPevents += New-Object -TypeName PSObject -Property @{ | |
ComputerName = $env:computername | |
User = $event.Properties[0].Value | |
Domain = $event.Properties[1].Value | |
SourceNetworkAddress = [net.ipaddress]$Event.Properties[2].Value | |
TimeCreated = $event.TimeCreated | |
Result = $result | |
} | |
} | |
$RDPevents | Format-Table |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment