Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

How to output to two columns

How to output to two columns

How to output to two columns

I am using a module to query a backup product and need (what I thought would be simple) the output of the commands to create the output side by side.


Node Serial
node1 12345
node2 56789
node3 10112

I query the data I need using
$backupnode = GetBackupNode
$backupnode = Get-BackupNode.hostname
$backupserial = Get=BackupSerial.id

I've then outputted that with write-output and I get the nodes and serials on top of one another.
Is this a simple thing to do as I have tried foreach and while statements that have failed to provide the output.

Apologies if this is something simple.

RE: How to output to two columns

I would use a custom object then export the results. Not knowing how your data is structured, I can only give you an idea of what it would look like.

CODE --> PowerShell

$backups = @()

#<Get Data somehow>
Foreach ($backup in $backups)

$backupnode = GetBackupNode
$backupnode = Get-BackupNode.hostname
$backupserial = Get=BackupSerial.id

# Create Object
$backup_info = New-Object PSObject
$backup_info | Add-Member -Type NoteProperty -Name 'Node' -Value $backupnode
$backup_info | Add-Member -Type NoteProperty -Name 'Serial' -Value $backupserial

#Save individual data
$backups += $backup_info
$backups | Export-Csv "C:\Temp\MyBackupFile.csv" -NoTypeInformation 

Something like that

Light travels faster than sound. That's why some people appear bright until you hear them speak.

RE: How to output to two columns

That's really good of you to reply, I am not sure if people are ever interested in seeing posters attempts.
I did start to go down the object route but from the above I can see I'd confused the foreach too.
I used foreach($backuphost in $backupnode)

Also I made an error in the original post, but I dont think it will matter too much:
$backupnode = GetBackupNode
$backupnode = Get-BackupNode.hostname
$backupserial = Get=BackupSerial.id

Should have read:

$backupnode = GetBackupNode
$backuphost = Get-BackupNode.hostname
$backupserial = Get=BackupSerial.id

Thank you again.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close