I am trying to get the last reboot time of some PCs from a list. When I use
foreach ($pc in $pclist) {
Get-CimInstance -ClassName win32_operatingsystem -ComputerName $pc |
select csname, lastbootuptime
}
The output comes as following.
<pre>csname lastbootuptime ------ -------------- CONFA7-L1-1A 7/15/2016 9:55:16 AM CONFA7-L1-1F 5/31/2016 8:51:46 AM CONFA7-L1-1G 6/18/2016 11:09:15 AM CONFA7-L1... 6/26/2016 5:31:31 PM CONFA7-L3... 7/24/2016 3:48:43 PM</pre>Which is neat, but if the PC name is long, I am unable to see the full name.
So I pipelined Format-Table
:
Get-CimInstance -ClassName win32_operatingsystem -ComputerName $pc |
select csname, lastbootuptime |
Format-Table -HideTableHeaders
And this is what I get:
<pre>CONFA7-L1-1A 7/15/2016 9:55:16 AM CONFA7-L1-1E 7/21/2016 12:58:16 PM CONFA7-L1-1F 5/31/2016 8:51:46 AM</pre>There are two problems here.
-
There is no heading. If I remove
-HideTableHeaders
there will be heading for every output which is not required. -
There is a lot of white spaces in between.
Basically I just need to get an output similar to the first one, but without truncating the full names. How can I fix these?