PowerShell – How to run an EncodedCommand using a Bat file

If you don’t want to expose the PowerShell script logic to your end users,

you can use the EncodedCommand switch to run Base64 Encoded files.


Next if you don’t want to give the PowerShell command or PS IDE you can use just a Bat file instead.


But this is challenging to get it all working. Confused smile



1. Create a Bat file that calls the Encoded PowerShell script :

Like this …


Powershell -file "C:\TEMP\OUTBOUND_Logfiles.ps1"



Next create an EncodedCommand PowerShell script :

Like this …

powershell.exe -EncodedCommand "JABmAGkAbABlAHMAIAA9ACAARwBlAHQAL...."



If you want to use the Out-GridView for showing the output in a GUI.

You will need to at this to the end of the script in order to keep the GridView Open at the end.


Read-Host "press enter to exit"



Otherwise the GridView will not remain open at the end when the script finished Smile


Enjoy !!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

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

%d bloggers like this: