1

I have a PowerShell script. This:

Get-Printer | ft name,portname,location | Export-Csv c:\intel\intvprint2.csv -NoTypeInformation

But it isn't any good :( I made the script, but the result is file error data.

This it makes:

"ClassId2e4f51ef21dd47e99d3c952918aff9cd","pageHeaderEntry","pageFooterEntry","autosizeInfo","shapeInfo","groupingEntry"
"033ecb2bc07a4d43b5ef94ed5a35d280",,,,"Microsoft.PowerShell.Commands.Internal.Format.TableHeaderInfo",
"9e210fe47d09416682b841769c78b8a3",,,,,
"27c87ef9bbda4f709f6b4002fa4af63c",,,,,

But now see this:

Get-Printer | ft name,portname,location

name                          portname               location
----                          --------               --------
9620HP2055DN                  172.17.252.130         loc1
9590HP2055DN                  172.17.239.45          loc2

Why isn't the script good?

4

1 Answer 1

5

ft is an alias for Format-Table, which is meant to output the data pretty in a terminal. You want to use Select-Object (alias select) instead.

Get-Printer | select name,portname,location | Export-Csv c:\intel\intvprint2.csv -NoTypeInformation
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.