Keeping leading 0s in Azure Automation Powershell parameter

Hi, I am trying to create folders in SharePoint with an Azure Automation Powershell script. The script accepts a Job Number, Project Number, and Job Name in order to create the root folder. The user that is going to be using this script wants to have the folder be named “Job Number - Project Number - Job Name”, and he wants the Job Number to be in the form of 001, 002, 003 etc.

Currently, when a number with leading 0s is passed into the Azure Automation script, the leading 0s all disappear. I’m not sure how to fix this behavior.

Current Implementation


Write-Output $JobNumber; 
#Prints '3'

$jobUrl = "Shared Documents/General/01 - Projects/$($JobNumber) - $($ProjectNumber) - $($JobName)"; 
#Prints 'Shared Documents/General/01 - Project/3 - ##### - abcdefg

Azure Automation Inputs

Any help you can give on this is appreciated.


welcome to the forums.
The easiest way to format a number with leading zeros is to use the format operator.

$jobUrl = 'Shared Documents/General/01 - Projects/{0:d3} - {1:d3} - {2}' -f $JobNumber, $ProjectNumber, $JobName