Skip to content

Get-LoggedOnUsers - -WarningVariable variable is not populating  #11

Description

@C9312B4DC0

When attempting to use the Get-LoggedOnUsers, I tried to use the -WarningVariable parameter to capture all servers that had WMI and RPC warnings.

When accessing the Warning Variable, the output is empty.

Example:

Process {
        if ( $PsCmdlet.ParameterSetName -like 'SingularHost' ) {
            $LoggedOnUsers = Get-LoggedOnUsers -Computer $ComputerName -WarningAction SilentlyContinue -WarningVariable WarningOutput
        }
        else {
            $LoggedOnUsers = Get-EnabledADComputers -HostType $HostType | Get-LoggedOnUsers -Property DNSHostName -WarningAction SilentlyContinue -WarningVariable WarningOutput
        }

        $WarningOutput | Measure-Object #---> Output is zero

        ($WarningOutput).Count #---> Output is zero
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedExtra attention is needed

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions