Solved

powershell number format with commas

Posted on 2013-12-31
4
796 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
Comment Utility
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 68

Accepted Solution

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

Open in new window

0
 
LVL 18

Assisted Solution

by:Raheman M. Abdul
Raheman M. Abdul earned 250 total points
Comment Utility
$numbers = $recnum, $TotalRecordCount

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

Author Closing Comment

by:johnj_01201
Comment Utility
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Are you one of those front-line IT Service Desk staff fielding calls, replying to emails, all-the-while working to resolve end-user technological nightmares? I am! That's why I have put together this brief overview of tools and techniques I use in o…
Microsoft Windows Server Update Service (WSUS) is free for everyone, but it lacks of some desirable features like send an e-mail to the administrator with the status of all computers on the WSUS server. This article is based on my PowerShell script …
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This video discusses moving either the default database or any database to a new volume.

772 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now