P
P
PGdisco2019-01-29 13:07:22
PowerShell
PGdisco, 2019-01-29 13:07:22

How to change output of powershell command response?

I query computers in the domain using the command

Get-WMIObject -Class Win32_ComputerSystem -Computer name |Select-Object Username

And everything would be fine, but it returns the answer as a column of the table
5c5025451385f940686123.png
. How to output as a single line?
The matter is that I substitute names of computers a cycle and in passing I collect some more values. Further, I write these values ​​​​into a txt file, separated by commas, and this table header breaks everything.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Andrew AT, 2019-01-29
@AAT666

Get-WMIObject -Class Win32_ComputerSystem -Computer name | Select-Object -ExpandProperty Username

A
azarij, 2019-01-29
@azarij

(Get-WMIObject -Class Win32_ComputerSystem -Computer name).username

S
Sergey, 2019-02-04
@LiS-31

Play around with the Format-Table or Format-list
command For example:
You may need Format-Wide

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question