How to use PShellExecPShellExec is a free tool that interacts with the user to secure and execute PowerShell scripts, or it can run unattended. The ShellServe™ option lets users execute scripts from a web browser.
To download the latest version visit this safe
download site. Other safe download sites are Softpedia and CNet.
PShellExec uses several methods to protect your PowerShell scripts from prying eyes. It deters unauthorized use and intellectual property theft - click here for more information. Starting with version 1.3.1 PShellExec includes a GUI interface and can be used with PowerGUI's Script Editor via a free Add-on. Feel free to make a small donation to help us improve PShellExec. As our thank you note, you will receive a guide on how to create easily your own custom protection code, for enhanced script security. PrerequisitesPShellExec requires PowerShell Version 2.0 or later and runs under the following Windows Systems: - Windows 10 / 8 / 7 / Vista / XP - Windows Server 2012 / 2008 / 2003 To enable better script compression and stronger security options for users, PShellExec uses the free 7-Zip utility. To use this option, first download 7-Zip and install it or download just the command-line utility 7za.exe and place the in PShellExec's install directory.
Installation
PShellExec is distributed as zip file, containing several files: PShellExec.exe,
licence.txt, HowToUse.html, HowToShellServe.html, ShellServe.html, sample
scripts ConsoleTest.ps1 and a setup command for the ShellServe™
configuration. ShellServe™ is an option that allows users execute PowerShell scripts from a web browser on any device. PShellExec does NOT require any other install/uninstall procedures and it does NOT modify the Windows Registry. All claims to the contrary are bogus. Release notesVersion 2.1.0 - ShellServe service updates and Checksum verification - SHA256: 3A888D7E39083A10827AD25AF083D60E8E65CF6177CE57D5AE73FB752DF9E77D Version 2.0.0 - Adds 'Randomize' option to generate random names in a script Version 1.8.6 - Fixes Close and Exit issues Version 1.8.5 - Changes in GUI and ShellServe optimizations Version 1.8.0 - Adds ShellServe™ web service for executing scripts from a browser; Creates shortcuts for script execution. Version 1.7.0 - Adds GUI support for Write-Progress cmdlet and PromptForChoice; Improves the 7-Zip interface Version 1.6.2 - Fixes for 64 bit Windows OS Version 1.6.1 - Checks for PowerShell Version 2.0 or later requirement Version 1.6.0 - Adds script drag & drop and security enhancements (Requires new .ps1.bin file creation) Version 1.5.0 - Provides enhanced script security (Requires new .ps1.bin file creation) Version 1.4.5 - Fixes console display. Version 1.4.4 - Fixes in /a and /f switch prompts handling. Version 1.4.3 - Fixes in GUI Interface; Version 1.4.2 - Fixes in GUI Interface; Fixes in 7zip (/c switch) handling. Version 1.4.1 - Changes in /a: arguments handling; Support for Get-Credential command. Version 1.4.0 - Changes in GUI Interface; Smaller .ps1.bin files; New $PSExecName variable. Version 1.3.2 - New GUI Interface; Changes in Console interactions.
ExamplesBelow are examples of command line parameters for running PShellExec. To run with the GUI, simply start PShellExec. How to create a secured script file1) PShellExec example.ps1 /e 2) PShellExec example.ps1 /e /p:yourpwd 3) PShellExec example.ps1 /e /b:yourpwd The examples create a secured example.ps1.bin script file in the same directory. The first example creates a secured example.ps1.bin script file without a password. Anyone can subsequently run PShellExec with this secure script file as input. The second and third examples create a secured example.ps1.bin script file with a password. In Example 3 the password is base64 encoded. Only users who have the password can run PShellExec with a password secured script. If you loose or forget the password, password secured scripts become useless! Keep your password and original .ps1 scripts in a safe place. Passwords must have at least 4 characters. If you omit entering a password following the /p: or /b: parameters on the command line, PShellExec will prompt for it. For better script compression and security, use the /c switch. See the 7-Zip prerequisites section above for this option. Please NOTE that not all versions of this utility are downward compatible with older .ps1.bin files. How to execute a script filePShellExec executes all scripts in memory and does not allow users to view or change secured scripts. 1) PShellExec example.ps1 2) PShellExec example.ps1.bin /p:yourpwd 3) PShellExec example.ps1.bin /b:yourpwd 4) PShellExec example.ps1 /a:"-period, Monthly, -days,'30 days'" 5) PShellExec example.ps1.bin /p:yourpwd /f:"myFunction 'abc' '123' " The first example executes an unsecured example.ps1 script file. Use it to test your script and its output before securing it. The second and third examples execute a secured example.ps1.bin script file with a user provided password. If you omit entering a password following the /p: or /b: parameters on the command line, PShellExec will prompt for it. Example 4 passes arguments to a script that is expecting four arguments. Use as many /a: command parameters as required and in the order expected by your script. Note that for arguments starting with a question mark, PShellExec will prompt for their values. For instance, /a:"?Monthly" will prompt for a replacement value for the argument, before executing the script. Starting with PShellExec version 1.4.1 the arguments are comma separated. In example 5 the script execution starts with the function named myFunction defined inside the script, passing it the strings 'abc' as its first parameter and '123' as its second parameter. PShellExec will prompt for values for parameter strings starting with a question mark: '?abc' will ask you to enter a parameter. NOTE: Use the /c switch, if the input script is compressed and was created with the same switch. Starting with version 1.6 users can drag and drop script files in the PShellExec window.
How to use the console and built-in variablesUse the /s command line parameter to submit the console output to the Clipboard when the script ends. The script file ConsoleTest.ps1, part of the download, contains examples of console input and output, including secure string handling. Run "PShellExec ConsoleTest.ps1 /s" to see its console interactions.
PShellExec prompts the user for input using a dialog box.
In order to be prompted at the command line, users can run the following command in Windows PowerShell Run as administrator: The built-in variable $MyInvocation used in scripts with PShellExec returns empty or null for: $MyInvocation.ScriptName, $MyInvocation.InvocationName, $MyInvocation.MyCommand.Name and $MyInvocation.MyCommand.Path (when used outside a function.) $PSExecName is a variable made available by PShellExec to users. $PSExecName is a string with the full script filename, including its path. An example of its use is shown in ConsoleTest.ps1. $PSExecOut is another variable made available by PShellExec to users of ShellServe™. The response users would like to see from the browser invoked script should be assigned to $PSExecOut. See SQLInfo.ps1 for an example of how $PSExecOut is used. How to package additional files with you scriptUse the 7-Zip compression utility (Compressed option of PShellExec) to secure the script. A second option is to manually rename the .ps1.bin file extension to .ps1.zip and then use the 7-Zip file manager 7zFM.exe to drag-and-drop the additional files. All files are extracted automatically and every time PShellExec executes the .ps1.zip script. Note that newly added files using 7-Zip are not password protected. How secure is secure?Several methods are used in PowerShell to secure and execute scripts in memory.
© 2010-2016 infoSpectrum
Inc. All trademarks and names are property of their respective owners.
|