Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 960
  • Last Modified:

powershell number format with commas

How can I get this to display on one line with commas in the numbers?
write-host Processing Record# $recnum of $TotalRecordCount

I've only found examples like this:
http://technet.microsoft.com/en-us/library/ee692795.aspx

I do not know how to use those examples inline with text, only on single lines.
thanks
0
johnj_01201
Asked:
johnj_01201
2 Solutions
 
Jeremy WeisingerSenior Network Consultant / EngineerCommented:
It depends on where you're using it but generally you would insert something like this:

("{0:N0}" -f $a)

Open in new window

$a can be any variable that contains a number or you can just write the number itself.
0
 
QlemoC++ DeveloperCommented:
Simply use
write-host ("Processing Record# {0:N0} of {1:N0}" -f $recnum, $TotalRecordCount)

Open in new window

0
 
Raheman M. AbdulSenior Infrastructure Support Analyst & Systems DeveloperCommented:
$numbers = $recnum, $TotalRecordCount

"Processing  Record# {0:N0} of {1:N0} " -f $numbers
0
 
johnj_01201Author Commented:
The write-host example is what I need, and the $numbers examples is cool - I did not know we could do that. The write-host example is also like C code too which is another help. The $numbers example is a little beyond how I currently think- putting 2 numbers into one number, which I'm guessing is a PS object which explains why it works.
THANK YOU!
0

Featured Post

Has Powershell sent you back into the Stone Age?

If managing Active Directory using Windows Powershell® is making you feel like you stepped back in time, you are not alone.  For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now