?
Solved

powershell number format with commas

Posted on 2013-12-31
4
Medium Priority
?
885 Views
Last Modified: 2013-12-31
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
Comment
Question by:johnj_01201
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 19

Expert Comment

by:Jeremy Weisinger
ID: 39748320
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
 
LVL 70

Accepted Solution

by:
Qlemo earned 1000 total points
ID: 39748340
Simply use
write-host ("Processing Record# {0:N0} of {1:N0}" -f $recnum, $TotalRecordCount)

Open in new window

0
 
LVL 19

Assisted Solution

by:Raheman M. Abdul
Raheman M. Abdul earned 1000 total points
ID: 39748361
$numbers = $recnum, $TotalRecordCount

"Processing  Record# {0:N0} of {1:N0} " -f $numbers
0
 
LVL 1

Author Closing Comment

by:johnj_01201
ID: 39748400
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
Windows 10 came with  a lot of built in applications, Some organisations leave them there, some will control them using GPO's. This Article is useful for those who do not want to have any applications in their image (example:me).
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question