PowerShell String Output Control
-
Friday, January 18, 2013 1:23 AM
Hi
I started using a ps1 to list dirs and sizes over at http://gallery.technet.microsoft.com/scriptcenter/Outputs-directory-size-964d07ff
The output truncates the path to 40 characters so i can't see the true path. So this lead me to this post, on hints on how to control the width of strings in output ?
e.g. code has @{Name="Path"; Expression={$directory.FullName}},
which has no explicit 40 chars but it happens
>> Where can i find help on the "Expression=" syntax ? I tried google and MSDN, but it discards the "=" and finds info on regular expressions. I can't find help on this, and if there is a syntax which means "display all characters"?p.s >> would be nice how to force commas every 3 digits in large numbers ?
@{Name="Files"; Expression={"{0:N0}"Thanks in advance
- Edited by Greg B Roberts Friday, January 18, 2013 1:31 AM
All Replies
-
Friday, January 18, 2013 1:51 AMModerator
Hi,
The script isn't truncating the data; default formatter is. You can see it all by piping to Format-List:
PS C:\Scripts> get-dirstats "C:\Dir Name" | format-list
Also, that script has a -FormatNumbers parameter that formats the numbers for you.
Bill
- Marked As Answer by Greg B Roberts Friday, January 18, 2013 10:43 PM
-
Friday, January 18, 2013 2:39 AM
Thanks Bill
Do you know where the "Expression=" help can be found ?
Thanks
-
Friday, January 18, 2013 2:40 AMModerator
Also, you might find it helpful to read the entire blog entry about the script:
Getting Directory Sizes in PowerShell
Bill
- Marked As Answer by Greg B Roberts Friday, January 18, 2013 10:44 PM

