Skip to content

Commit

Permalink
field ordering match
Browse files Browse the repository at this point in the history
  • Loading branch information
TonyPhipps authored Dec 4, 2023
1 parent 93c651b commit d3d79e7
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Modules/Get-Sessions.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -64,17 +64,17 @@ function Get-Sessions {
$first = 1
$ResultsArray = qwinsta 2>$null | ForEach-Object {
if ($first -eq 1) {
$userPos = $_.IndexOf("USERNAME")
$sessionPos = $_.IndexOf("SESSIONNAME") # max length 15
$userPos = $_.IndexOf("USERNAME")
$idPos = $_.IndexOf("ID") - 2 # id is right justified
$statePos = $_.IndexOf("STATE") # max length 6
$typePos = $_.IndexOf("TYPE") # right justified too
$devicePos = $_.IndexOf("DEVICE")
$first = 0
}
else {
$user = $_.substring($userPos,$userPos-$sessionPos).Trim()
$session = $_.substring($sessionPos,$userPos-$sessionPos).Trim()
$user = $_.substring($userPos,$userPos-$sessionPos).Trim()
$id = [int]$_.substring($idPos,$statePos-$idPos).Trim()
$state = $_.substring($statePos,$typePos-$statePos).Trim()
$type = $_.substring($typePos,$devicePos-$typePos).Trim()
Expand Down

0 comments on commit d3d79e7

Please sign in to comment.