Skip to content

Commit b2fc317

Browse files
authoredSep 28, 2018
update Get-UserLogonSessionHistory.ps1
fix end session event change output to lines
1 parent b1b9a04 commit b2fc317

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed
 

‎ActiveDirectory/Get-UserLogonSessionHistory.ps1

+3-3
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ try
7676
$_.TimeCreated -gt $LogonTime -and
7777
$_.ID -in $SessionStopIds -and
7878
(([xml]$_.ToXml()).Event.EventData.Data | where { $_.Name -eq 'TargetLogonId' }).'#text' -eq $LogonId
79-
}) | select -First 1
79+
}) | select -last 1
8080
if (-not $SessionEndEvent) ## This be improved by seeing if this is the latest logon event
8181
{
8282
Write-Verbose -Message "Could not find a session end event for logon ID [$($LogonId)]. Assuming most current"
@@ -98,7 +98,7 @@ try
9898
'Session Active (Days)' = [math]::Round((New-TimeSpan -Start $LogonTime -End $LogoffTime).TotalDays, 2)
9999
'Session Active (Min)' = [math]::Round((New-TimeSpan -Start $LogonTime -End $LogoffTime).TotalMinutes, 2)
100100
}
101-
[pscustomobject]$output
101+
[pscustomobject]$output | ft -AutoSize -HideTableHeaders
102102
}
103103
}
104104
})
@@ -111,4 +111,4 @@ try
111111
catch
112112
{
113113
$PSCmdlet.ThrowTerminatingError($_)
114-
}
114+
}

0 commit comments

Comments
 (0)
Please sign in to comment.