Quser.json

{
    "$schema": "https://aka.ms/PowerShell/Crescendo/Schemas/2021-11",
    "Examples": [
        {
            "Command": "Get-LoggedOnUser",
            "Description": "Display session information about user(s) logged on to the local system.",
            "OriginalCommand": "quser"
        },
        {
            "Command": "Get-LoggedOnUser -Identity 'testuser'",
            "Description": "Display session information on 'testuser'.",
            "OriginalCommand": "quser testuser"
        },
        {
            "Command": "Get-LoggedOnUser -ComputerName 'REMOTEPC'",
            "Description": "Display session information about user(s) logged on to remote system.",
            "OriginalCommand": "quser /SERVER:REMOTEPC"
        }
    ],
    "Commands": [
        {
            "Verb": "Get",
            "Noun": "LoggedOnuser",
            "Platform": ["Windows"],
            "OriginalName": "$env:windir/System32/quser.exe",
            "DefaultParameterSetName": "Default",
            "Usage": {
                "Synopsis": "Display information about users logged on to the system."
            },
            "Parameters": [
                {
                    "Description": "Name of local or remote computer",
                    "ParameterSetName": ["Default"],
                    "Name": "ComputerName",
                    "Mandatory": false,
                    "ValueFromPipeline": true,
                    "ValueFromPipelineByPropertyName":true,
                    "Position": 1,
                    "NoGap": true,
                    "OriginalName": "/SERVER:",
                    "ParameterType": "string"
                },
                {
                    "Name": "Identity",
                    "ValueFromPipelineByPropertyName":true,
                    "ParameterSetName": ["Default"],
                    "OriginalName": null,
                    "Mandatory": false,
                    "Position": 0,
                    "Description": "This value can be username, sessionname or sessionID.",
                    "ParameterType": "string"
                }
            ],
            "OutputHandlers": [
                {
                    "Handler": "param([object[]]$Lines,$Skip = 1)
                    $Lines | Select-Object -Skip $skip | ForEach-Object {
                        $columns = $_ -split '\\s{2,}' | Where-Object {$_ }
                        if($columns.count -eq 5)
                        {
                            [pscustomobject]@{
                                UserName = [String]($columns[0] -replace '>').trim()
                                SessionName = $null
                                ID = [String]$columns[1]
                                State = [String]$columns[2]
                                IdleTime = [String]$columns[3]
                                LogonTime = Get-Date $columns[4]
                            }
                        }else{
                            [pscustomobject]@{
                                UserName = [String]($columns[0] -replace '>').Trim()
                                SessionName = [String]$columns[1]
                                ID = [String]$columns[2]
                                State = [String]$columns[3]
                                IdleTime = [String]$columns[4]
                                LogonTime = Get-Date $columns[5]
                            }
                        }
                        }",
                    "ParameterSetName": "Default"
                }
            ],
            "OriginalText":"Display information about users logged on to the system."
        }
    ]
 }