• Skip to primary navigation
  • Skip to main content
  • Skip to footer

Stephanos Constantinou Blog

PowerShell Scripting

  • Home
  • Blogs
    • PowerShell Tutorials
    • PowerShell Scripts
    • PowerShell Modules
      • Modules Cmdlets
    • Software Reviews
  • About
  • Contact
You are here: Home / PowerShell Tutorials / PowerShell Special Characters

PowerShell Special Characters

29/06/2018 by Stephanos Leave a Comment

PowerShell Special Characters

As in every programming and scripting language, in PowerShell there are special characters that you can use to represent characters, that we are not able to find in the standard set. In this tutorials we will see those PowerShell special Characters and what is their use.

All special characters in PowerShell start with backtick (` ). You can use the special characters only within double quotes ( " " ). If they are used otherwise, they will not be interpreted to the desired one. First of all we will see the list of characters and then we will go through it to see more details for each of the special characters. The list is provided by Microsoft.

Special Characters List:

  • `0 – Null
  • `a – Alert
  • `b – Backspace
  • `e – Escape
  • `f – Form Feed
  • `n – New Line
  • `r – Carriage Return
  • `t – Horizontal Tab
  • `u{x} – Unicode Escape Sequence
  • `v – Vertical Tab
  • --%  – Stop Parsing

Null

`0 

The null character is presented in PowerShell output as an empty space. It is not the same with $null variable. As per Microsoft, this allows you to use Windows PowerShell to read and process text files that use null characters, such as string termination or record termination indicators.

Alert

`a 

The Alert character can send a beep sound to the computer’s speaker. You can use this character to warn the user for an action that he is trying to perform.

[adinserter name=”In Article”]

Backspace

`b 

The backspace character will move the cursor 1 character backwards. Although, when we are using backspace on our keyboard, the cursor is moved 1 character back and removes the last character. When you use it in PowerShell it will move only the cursor back by one character. In order to remove the characters also, you need to provide the characters that will replaced those after the cursor. As you can see below when I use on the backspace character and not provide anything, Windows PowerShell output gives me the the same words I provide to it. On the second example, that I provide new characters after the backspace, you can see the the word “World has been replace with “Everyone”.

Example:

PowerShell Special Characters - Backspace

Escape

`e 

As provided by Microsoft:

The escape character is most commonly used to specify a virtual terminal sequence (ANSI escape sequence) that modifies the color of text and other text attributes such as bolding and underlining. These sequences can also be used for cursor positioning and scrolling. The PowerShell host must support virtual terminal sequences. This can be checked on PowerShell v5 and higher with the boolean property $Host.UI.SupportsVirtualTerminal.

Form Feed

`f 

The form feed character (`f) is a print instruction that ejects the current page and continues printing on the next page. This character affects printed documents only; it does not affect screen output.

[adinserter name=”In Article”]

New Line

`n

The new line character inserts a line break immediately after the character and continues the text from that line.

Example:

PowerShell Special Characters - New Line

Carriage Return

`r 

The carriage return character will not output any text prior to it. It considers anything prior to it as a different line. As you can see in the example below you can combine it with new line character and then both parts of the text will be provided to output.

Example:

PowerShell Special Characters - Carriage Return

 

[adinserter name=”In Article”]

Horizontal Tab

`t 

The horizontal tab character goes to the next tab and continues the rest of the text from that point. As per Microsoft, the default for Windows PowerShell tab space is 8 spaces.

Example:

PowerShell Special Characters - Horizontal Tab

Unicode Escape Sequence

`u{x} 

As provided by Microsoft:

The Unicode escape sequence allows you to specify any Unicode character by the hexadecimal representation of its code point. This includes Unicode characters above the Basic Multilingual Plane (> 0xFFFF) which includes emoji characters e.g. `u{1F44D}. The Unicode escape sequence requires at least one hex digit and supports up to six hex digits. The maximum hex value for the sequence is 10FFFF.

[adinserter name=”In Article”]

Vertical Tab

`v 

The vertical tab character goes to the next vertical tab and continues to write the rest part of the text. It can only affect the document printouts. Nothing will be done on the screen.

Stop Parsing

--%

As provided by Microsoft:

The stop-parsing symbol (–%) prevents Windows PowerShell from interpreting arguments in program calls as Windows PowerShell commands and expressions. Place the stop-parsing symbol after the program name and before program arguments that might cause errors.

Example:

PowerShell Special Characters - Stop-Parsing

I hope the tutorial about PowerShell Special Characters is helpful.

Please let me know your comments and thoughts.

You feedback is appreciated.

[adinserter name=”In Article”]

Related Links:

  • PowerShell Tutorials
  • PowerShell Scripts
  • about_Special_Characters | Microsoft Docs

[adinserter name=”Matched-Content”]

Summary
PowerShell Special Characters
Article Name
PowerShell Special Characters
Description
PowerShell Special Characters. In this tutorial, you will find the PowerShell special characters and their use. Stephanos Constantinou Blog
Author
Stephanos
Publisher Name
Stephanos Constantinou Blog
Publisher Logo
Stephanos Constantinou Blog

Filed Under: PowerShell Tutorials Tagged With: Special Characters

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Footer

Recent Posts

  • ICS Cube Product Review 26/04/2019
  • PowerShell Module SysInfo v1.2.0 15/03/2019
  • PowerShell Module SysInfo v1.1.2 13/11/2018
  • PowerShell Module SysInfo 24/10/2018
  • Get-VoltageProbe 24/10/2018
  • Get-VideoController 24/10/2018
  • Get-USBController 24/10/2018
  • Get-TrackPoint 24/10/2018
  • Get-TrackBall 24/10/2018
  • Get-TouchScreen 24/10/2018
Planet PowerShell

Categories

  • Modules Cmdlets (57)
  • PowerShell Modules (5)
  • PowerShell Scripts (38)
  • PowerShell Tutorials (35)
  • Software Reviews (2)

Archives

  • April 2019 (1)
  • March 2019 (1)
  • November 2018 (1)
  • October 2018 (56)
  • September 2018 (13)
  • August 2018 (9)
  • July 2018 (6)
  • June 2018 (8)
  • May 2018 (7)
  • April 2018 (9)
  • March 2018 (4)
  • February 2018 (6)
  • January 2018 (12)
  • December 2017 (4)
Top 10 PowerShell 2018

Blogroll

  • Planet PowerShell
  • Reddit – PowerShell
  • PowerShell Magazine
  • PowerShell.org
  • PowerShell Team Blog
  • Hey, Scripting Guy! Blog
  • Mike F Robbins
  • PowerShell Explained with Kevin Marquette
  • Mike Kanakos – Network Admin
  • The Lonely Administrator
  • AskME4Tech
PowerShell Blogs Sysadmin Blogs Banners for Top 20 Programming Blogs

© 2023 · Stephanos Constantinou Blog

  • Home
  • Blogs
  • About
  • Contact