Get-WMIObject -class Win32_ComputerSystem | select username返回空输出

时间:2018-02-14 11:55:11

标签: powershell remoting logged

我有一位用户通过RDP使用用户名“英雄”登录,但是当我String query = String query = String query = 'SELECT id, ELC_SubStatus__c FROM Case WHERE SubStatus__c ='+ refund +' AND createdDate < LAST_N_DAYS:10'; 使用该计算机并运行Enter-PSSesssion时,我得到了此输出:

Get-WMIObject -class Win32_ComputerSystem | select username

1 个答案:

答案 0 :(得分:1)

以下是here:

的答案
# replace $computer with your remote machine
$csvtxt=QWINSTA /SERVER:$computer|%{[string]::Join(',',$_.Split(' ',
  [StringSplitOptions]::RemoveEmptyEntries))}
$csv=ConvertFrom-Csv $csvtxt
$csv

这会将QWINSTA的输出解析为PSObject,从这里你可以做到:

$csv | Select USERNAME