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
精彩评论