开发者

Echo objects in Powershell with two different AD objects in them results them being put in the same table

I have two objects from an AD query in two variables, when I echo them they always end up in the same table. Very anoying.

For example

Echo "Users:"
$InactiveUsers | select name

Echo "Computers:"
$InactiveComputers | select nam开发者_StackOverflow中文版e, lastlogondate

This should give me this result

Users:
name
----
John

Computers:
name                              lastlogondate
----                              -------------
JohnComputer                      1.1.2011

But instead I get it like this

Users:
name
----
John
Computers:
JohnComputer

What am I doing wrong?


Your problem is your script is outputting more than one type of object (three in fact). If you truely want to throw out the objects and just want tables, do this.

Write-Host "Users:"
$InactiveUsers | Select name | Out-Host

Write-Host "Computers:"
$InactiveComputers | Select name, lastlogondate | Out-Host
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜