In some cases we want to hide the command to prevent users from seeing it as a clear text. PowerShell has a way of running Base64 encoded commands using -EncodedCommand Parameter
Base64 encoded string of a set of characters that contains only a-z, A-Z, 0-9, + and / and is often used in situations when sending non-text information via a text only transmission .
Script
############################################################################## ## ## PowerShell Encoded Command ## by Siva Mulpuru ## ############################################################################## cls $cmd = 'Write-Host "This is a Encrypted Text"' #encodes the characters, and returns the resulting bytes. $ubytes = [System.Text.Encoding]::Unicode.GetBytes($cmd) #Converts to Base64String; Refer - http://www.hcidata.info/base64.htm for indepth Base 64 Encoding $encodedcmd = [Convert]::ToBase64String($ubytes) write-Host "Encoded String is `n$encodedcmd" write-Host "Running Encoded Command --> " -NoNewline Powershell.exe -EncodedCommand $encodedcmd
Output
Please notice the big difference between encrypting and encoding things.