English 中文(简体)
PowerShell - Backtick
  • 时间:2024-12-22

Powershell - Backtick


Previous Page Next Page  

Backtick (`) operator is also called word-wrap operator. It allows a command to be written in multiple pnes. It can be used for new pne (`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 pne and tab.

> Write-host "Title Subtitle"
Title Subtitle

> Write-host "Title `nSubtitle"
Title 
Subtitle

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