Solved

powershell number format with commas

Posted on 2013-12-31
4
832 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
4 Comments
 
LVL 18

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 69

Accepted Solution

by:
Qlemo earned 250 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 250 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

Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

A procedure for exporting installed hotfix details of remote computers using powershell
A recent project that involved parsing Tableau Desktop and Server log files to extract reusable user queries for use in other systems. I chose to use PowerShell to gather the data, and SharePoint to present it...
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
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…

735 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