 
  Data Structure Data Structure
 Networking Networking
 RDBMS RDBMS
 Operating System Operating System
 Java Java
 MS Excel MS Excel
 iOS iOS
 HTML HTML
 CSS CSS
 Android Android
 Python Python
 C Programming C Programming
 C++ C++
 C# C#
 MongoDB MongoDB
 MySQL MySQL
 Javascript Javascript
 PHP PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How does string formatting work in PowerShell?
To format string in PowerShell, you can use -F operator. When you use -F format, you need to provide the argument number in the curly brackets.
Example
PS C:\> $Str = "Hello PowerShell" PS C:\> "{0}" -f $str Hello PowerShell For the multiple values,
PS C:\> $Str = "Hello PowerShell" PS C:\> $str1 = "Rockstart" PS C:\> "{0} says {1}" -f $Str,$str1 Hello PowerShell says Rockstart From the above example, we understood if we need to get the output for multiple variables using the -F operator then we can increment the number in curly brackets.
To use the above output with the Write-Output command,
PS C:\> Write-Output "{0} says {1}" -f $str,$str1 {0} says {1} -f Hello PowerShell Rockstart If we use the above method, the output will be messed up so to get the output in the correct format, we need to use the round bracket with Write-Output as shown below.
PS C:\> Write-Output ("{0} says {1}" -f $str,$str1) Hello PowerShell says RockstartAdvertisements
 