Windows Server TechCenter > Windows Server Forums > Windows PowerShell > Formatting output from a PS script
Ask a questionAsk a question
 

AnswerFormatting output from a PS script

  • Monday, November 02, 2009 11:11 PMLarsMK Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hi all!

    Is it possible to specify the format of the output from a script?

    I'm running "Get-MailboxDatabase | ft name,storagegroup" from a C# script and would like it to return something I can easily split up into variables. At the moment it separates with spaces, but I would like it to use tabs instead...

    Anyone?

    Cheers!

Answers

  • Tuesday, November 03, 2009 2:31 AMMarco ShawMVP, ModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    There's all kinds of options for formatting.  For example, this might work for you:
    PS>get-mailboxdatabase|foreach-object{$_.name+"`t"+$_.storagegroup}
    • Marked As Answer byLarsMK Tuesday, November 03, 2009 6:23 AM
    •  
  • Tuesday, November 03, 2009 12:04 PMMarco ShawMVP, ModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    Cool! Is `t a tab?

    Yes, check:
    PS>get-help about_Special_Characters

All Replies