Unicode emojis from Powershell
Unicode emojis from Powershell

Trevor has written a Powershell module that allows you to retrieve a Unicode emoji as a string. The cmdlet Get-Emoji has a -Name parameter with auto-completion to find easily the emoji names you want to use.

2016-04-29_13-26-49-1024x208

The installation steps

If you are behind a proxy with authentication, there is a tip to install properly the module. The following lines show how to use your current credential and set the proxy parameters:

PS \> $wc = New-Object System.Net.WebClient
PS \> $wc.Proxy.Credentials = [System.Net.CredentialCache]::DefaultNetworkCredentials
PS \> $wc.DownloadString('http://microsoft.com')Microsoft Corporation

Output

<html><head><title>Microsoft Corporation</title><meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7"></meta><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></meta><meta name="SearchTitle" content="Microsoft.com" scheme=""></meta><meta name="Description" content="Get product information, support, and news from Microsoft." scheme=""></meta><meta name="Title" content="Microsoft.com Home Page" scheme=""></meta><meta name="Keywords" content="Microsoft, product, support, help, training, Office, Windows, software, download, trial, preview, demo,  business, security, update, free, computer, PC, server, search, download, install, news" scheme=""></meta><meta name="SearchDescription" content="Microsoft.com Homepage" scheme=""></meta></head><body><p>Your current User-Agent string appears to be from an automated process, if this is incorrect, please click this link:<a ref="http://www.microsoft.com/en/us/default.aspx?redir=true">United States English Microsoft Homepage</a></p></body></html>

 

After that you can install the module (Powershell 5 is required)

PS \> Install-Module -Name Emojis

NuGet provider is required to continue
PowerShellGet requires NuGet provider version '2.8.5.201' or newer to interact with NuGet-based repositories. The NuGet
 provider must be available in 'C:\Program Files\PackageManagement\ProviderAssemblies' or
'C:\Users\youruseraccount\AppData\Local\PackageManagement\ProviderAssemblies'. You can also install the NuGet provider by
running 'Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force'. Do you want PowerShellGet to install
and import the NuGet provider now?
[Y] Yes  [N] No  [S] Suspend  [?] Help (default is "Y"): y

Untrusted repository
You are installing the modules from an untrusted repository. If you trust this repository, change its InstallationPolicy value by running the Set-PSRepository cmdlet. Are you sure you want to install the modules from 'PSGallery'?
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "N"): y
PS \> Get-Command -Module Emojis -CommandType All;

CommandType     Name                                               Version    Source
-----------     ----                                               -------    ------
Alias           emoji -> Get-Emoji                                 0.1        Emojis
Function        Get-Emoji                                          0.1        Emojis

 

If you want to find the full list of the available emojis you can use the following function:

function Get-ParameterOption {
    param(
        $Command,
        $Parameter
    )
 
    $parameters = Get-Command -Name $Command | Select-Object -ExpandProperty Parameters
     
    $type = $parameters[$Parameter].ParameterType
    if($type.IsEnum) {
        [System.Enum]::GetNames($type)
    } else {
        $parameters[$Parameter].Attributes.ValidValues
    }
}

 

After that, just test it and retrieve the emoji names :

PS \> Get-ParameterOption get-emoji name
GRINNING FACE
GRINNING FACE WITH SMILING EYES
FACE WITH TEARS OF JOY
SMILING FACE WITH OPEN MOUTH
SMILING FACE WITH OPEN MOUTH AND SMILING EYES
SMILING FACE WITH OPEN MOUTH AND COLD SWEAT
SMILING FACE WITH OPEN MOUTH AND TIGHTLY-CLOSED EYES
WINKING FACE
SMILING FACE WITH SMILING EYES
FACE SAVOURING DELICIOUS FOOD
SMILING FACE WITH SUNGLASSES
SMILING FACE WITH HEART-SHAPED EYES
FACE THROWING A KISS
KISSING FACE
KISSING FACE WITH SMILING EYES
KISSING FACE WITH CLOSED EYES
WHITE SMILING FACE
SLIGHTLY SMILING FACE
HUGGING FACE
SMILING FACE WITH HALO
NERD FACE
THINKING FACE
NEUTRAL FACE
EXPRESSIONLESS FACE
FACE WITHOUT MOUTH
FACE WITH ROLLING EYES
SMIRKING FACE
PERSEVERING FACE
DISAPPOINTED BUT RELIEVED FACE
FACE WITH OPEN MOUTH
ZIPPER-MOUTH FACE
HUSHED FACE
SLEEPY FACE
...

 

A total of 1624 possibilities ( (Get-ParameterOption get-emoji name).count )

 

If you are interested, find more informations here :
https://artofshell.com/2016/04/emojis-in-powershell-yes/
Poweshell gallery – Emoji project

<>

My Powershell script categories

Unicode emojis from Powershell

Leave a Reply

Your email address will not be published.