Format question

Ask your PowerShell-related questions, including questions on cmdlet development!
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 15 years and 3 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
vibe
Posts: 11
Last visit: Tue Jan 20, 2009 6:13 am

Format question

Post by vibe »

is there a better way to format a TAB delimeted line than the code below?


$output = $date +
User avatar
vibe
Posts: 11
Last visit: Tue Jan 20, 2009 6:13 am

Format question

Post by vibe »

specifically... I guess I want to output all of those variable to a file(tab separated) . Does that help?
User avatar
jhicks
Posts: 1789
Last visit: Mon Oct 19, 2015 9:21 am

Format question

Post by jhicks »

I can understand that but I'd say you aren't thinking the "PowerShell" way. Use objects or create your own:

$obj=new-object psobject
$obj | Add-member Noteproperty Date $date
$obj | Add-member Noteproperty DriveE $driveE
$obj | Add-member Noteproperty DriveF $driveF
$obj | Add-member Noteproperty DriveG $driveG
$obj | format-table -autosize

Or you can even pipe the line last line to Out-file

$obj | format-table -autosize | out-file results.txt

I suspect there's more going on with your task. This can be just part of it. The point is you shouldn't be trying to parse out strings. Work with objects.
This topic is 15 years and 3 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked