Skip to content
Menu
The Lonely Administrator
  • PowerShell Tips & Tricks
  • Books & Training
  • Essential PowerShell Learning Resources
  • Privacy Policy
  • About Me
The Lonely Administrator

Updated PowerShell Formatting Functions

Posted on August 19, 2015August 19, 2015

Last year I posted an article and a set of PowerShell functions to make it easier to format values. For some reason, I decided to revisit the functions and ended up revising and extending them. I modified Format-Value so that you can format a number as a currency or a number.

Manage and Report Active Directory, Exchange and Microsoft 365 with
ManageEngine ADManager Plus - Download Free Trial

Exclusive offer on ADManager Plus for US and UK regions. Claim now!


Format-Value help (Image Credit: Jeff Hicks)

The function is assuming you will pipe values to it.


Format-Value examples (Image Credit: Jeff Hicks)

I also wrote a new function called Format-String.


Format-String help (Image Credit: Jeff Hicks)

The nice thing is that you can apply as many or all of the formatting transformations as you want.


Format-String examples (Image Credit: Jeff Hicks)

The Replace option works by taking a hashtable and replacing each matching key with its value.


Using the Replace parameter in Format-String (Image Credit: Jeff Hicks)

One task that comes to mind where Format-String might come in handy is in building passwords.

The function contains the following aliases:

  • fp = Format-Percent
  • fv = Format-Value
  • fs = Format-String

I'm also trying something different, at least for me. Instead of posting the code here, I've started to use GitHub since that seems to be what all the cool kids are doing. You can find the FormatFunctions module at https://github.com/jdhitsolutions/FormatFunctions. This should also make it easier for me to post revisions, address bugs and make it easier for you to take my code and run with it. You're still welcome to post comments here, but use GitHub for anything specific to the PowerShell code.

Enjoy.

 


Behind the PowerShell Pipeline

Share this:

  • Click to share on X (Opens in new window) X
  • Click to share on Facebook (Opens in new window) Facebook
  • Click to share on Mastodon (Opens in new window) Mastodon
  • Click to share on LinkedIn (Opens in new window) LinkedIn
  • Click to share on Pocket (Opens in new window) Pocket
  • Click to share on Reddit (Opens in new window) Reddit
  • Click to print (Opens in new window) Print
  • Click to email a link to a friend (Opens in new window) Email

Like this:

Like Loading...

Related

reports

Powered by Buttondown.

Join me on Mastodon

The PowerShell Practice Primer
Learn PowerShell in a Month of Lunches Fourth edition


Get More PowerShell Books

Other Online Content

github



PluralSightAuthor

Active Directory ADSI Automation Backup Books CIM CLI conferences console Friday Fun FridayFun Function functions Get-WMIObject GitHub hashtable HTML Hyper-V Iron Scripter ISE Measure-Object module modules MrRoboto new-object objects Out-Gridview Pipeline PowerShell PowerShell ISE Profile prompt Registry Regular Expressions remoting SAPIEN ScriptBlock Scripting Techmentor Training VBScript WMI WPF Write-Host xml

©2025 The Lonely Administrator | Powered by SuperbThemes!
%d