我试图在同一行输出两个东西而不是新行,我不确定如何做或者甚至可能。
"Tag # Entered"; "-------------"; echo $tag1;
$OSInfo | Format-Table -Property @{Name="Resolved Tag #";Expression={$_.CSName}} -AutoSize;
我试图让它看起来像下面
Tag # Entered Resolved Tag #
------------- --------------
c63001 C63001
编辑以获得更多帮助:
$OSInfo `
| Format-Table -Property `
@{ Name = "Tag # Entered"; Expression = { $tag1 }; Width = 10 }, `
@{ Name = "Resolved Tag #"; Expression = { $_.CSName } };
还尝试将这两件事放在同一条线上,但它不起作用:
$domain = Get-WmiObject win32_computersystem -Computer $tag1 | Format-Table -Property @{Name="Username";Expression={$_.username}} -Autosize;
$username = (Get-WmiObject win32_computersystem -Computer $tag1).UserName.Split("\")[1];
$longname = ((net user $username /domain | Select-String "Full Name") -replace "Full Name","").Trim();
我试图用这个来做:
$Test `
| Format-Table -AutoSize -Property `
@{ Name = "Tag # Entered"; Expression = { $domain } }, `
@{ Name = "Resolved Tag #"; Expression = { $longname } };
答案 0 :(得分:2)
这应该为您提供所需的输出(重新格式化空白以便于阅读):
$OSInfo `
| Format-Table -AutoSize -Property `
@{ Name = "Tag # Entered"; Expression = { $tag1 } }, `
@{ Name = "Resolved Tag #"; Expression = { $_.CSName } };
请注意,如果$OSInfo
包含多个项目,则第一列的值对于所有项目都是相同的("c63001"
)。
答案 1 :(得分:0)
这就是我想要的:
$CompInfo `
| Format-Table -AutoSize -Property `
@{ Name = "Domain\user"; Expression = { $CompInfo.username } }, `
@{ Name = "Full Name"; Expression = { $fullname } };
它不起作用的原因是因为我使用的是$ OSInfo,它是win32_operatingsystem类。
$OSInfo = get-wmiobject -class win32_operatingsystem -computername $tag1;
$CompInfo = get-wmiobject -class win32_computersystem -Computer $tag1;
我尝试输出的域是使用win32_computersystem类提取的,我试图在win32_operatingsystem下进行。