Powershell - Backtick


Advertisements

Backtick (`) operator is also called word-wrap operator. It allows a command to be written in multiple lines. It can be used for new line (`n) or tab (`t) in sentences as well. See the examples below −

Example 1

Get-Service * | Sort-Object ServiceType `
| Format-Table Name, ServiceType, Status -AutoSize

It will become

Get-Service * | Sort-Object ServiceType | Format-Table Name, ServiceType, Status -AutoSize

Verify the output as

Name                                                   ServiceType  Status
----                                                   -----------  ------
MSSQLServerADHelper100                             Win32OwnProcess Stopped
ntrtscan                                           Win32OwnProcess Running
...

Example 2

Use of new line and tab.

> Write-host "Title Subtitle"
Title Subtitle

> Write-host "Title `nSubtitle"
Title 
Subtitle

> Write-host "Title `tSubtitle"
Title   Subtitle
Print

Useful Video Courses


Video

Powershell for beginners

15 Lectures 3.5 hours

Fabrice Chrzanowski

Video

Learning Task Automation using Windows PowerShell

35 Lectures 2.5 hours

Vijay Saini

Video

The Complete PowerShell 7 course: Beginner To Advanced

Most Popular

145 Lectures 12.5 hours

Fettah Ben

Advertisements