The Powershell script should deliver a clear message to the users so the users understand what’s going on. But won’t it be beautiful if Powershell can also add emojis such as 😁😊❤?

Requirements

  • A console that supports Unicode characters higher than the basic multilingual plane > 0xFFFF
  • For a better experience, download and install Windows Terminal. However, PowerShell ISE can be used but it has some limitations on how it displays the emojis.
  • Knowing the Unicode emoji you want to display, you can get it from the Unicode.org website

In this tutorial, we will use the Smiley Face emoji.

CodeEmoji picture
U+1F600

The easy way – PS7+ and Windows Terminal to show Powershell emojis

Windows Terminal is a very nice console that supports Windows Powershell and tabs, each tab can be a different PowerShell version. So let’s start by opening Windows Terminal

Windows Terminal

For PowerShell to display the emojis, first remove the U+ and escape the Hex value. In other words, this can be done by using the `u Powershell escape character.

Please note that the Unicode escape is featured in the Windows Powershell version 7. Read more about the PowerShell escape character from Microsoft Docs

The usage of `u is straight forward, `u{Unicode Hex}.

write-host `u{1F600}
Windows Terminal and Powershell 7 show a colored Emoji

In short, it’s very convincing to use Windows Terminal and PS7 and show emoji in one-liner of code.

Using Windows PowerShell 5.1 and ISE to display emojis

Windows Powershell version 5.1 don’t support the Unicode escape character `u, so some small manual work should be done.

Let’s display the Smiley face emoji which holds the U+1F600 Hex value. So first of all we need to remove the U+ from the equation and only keep the Hex value, in this case, 1F600, and then converting the Hex value to Int32. After that, convert the value to the UTF-16 string.

Firstly, the code below will convert the Hex value to Integer

$EmojiIcon = [System.Convert]::toInt32("1F600",16)
Converting from Hex to Int32

Secondly, convert the Unicode point which is stored in $EmojiIcon to UTF-16 String

[System.Char]::ConvertFromUtf32($EmojiIcon)

The output will be

Powershell Smiling 😀

All the Powershell Code for 5.1 ISE

$EmojiIcon = [System.Convert]::toInt32("1F600",16)
[System.Char]::ConvertFromUtf32($EmojiIcon)

Moreover, you can add this to Write-host or Write-output along with other text and apply certain color formating.

$EmojiIcon = [System.Convert]::toInt32("1F600",16)
 Write-Host "The Operation Completed Successfully " -NoNewline
 Write-Host -ForegroundColor Green ([System.Char]::ConvertFromUtf32($EmojiIcon))
 Write-Host ""
 Write-Host ""
Powershell Emoji with Write-host

In conclusion, as you can see, ISE won’t display emojis as colorful as Windows Terminal, plus it doesn’t support the display of all emojis, so this is why the recommendation is to use Windows Terminal.

Keep in mind that Powershell Console wont display any emoji

What Else to Read

Rate this post