Beginning with ISESteroids 184.108.40.206, when you obfuscate scripts, you now have an option to choose the type of obfuscation. You can currently choose from GUID, Binary, and Character. Let’s quickly check out what this means.
Before you read on, you might want to take a look at the first blog article about obfuscation which covers the basics and the appropriate use cases.
Obfuscating a Script
Obfuscating a script is simple: open the script that you want to obfuscate. Let’s assume this is your script:
Now, in the ISE menu, choose “Tools”, “Obfuscate”. A dialog pops up. You have a bunch of options. Use the combo box “Mode” to set the obfuscation mode. For example, choose “Character”. Also make sure you check “Create Obfuscation Table” so you get a list of changes that were applied to the obfuscated script.
A moment later, a new script opens in ISE. It looks vastly different, yet it still runs, just like the unobfuscated script:
Important note: Always make sure you save your original script or else you might lock yourself out as well. An obfuscated script is hard to understand and service. Also, please be aware that obfuscation is a work in progress and changes your original script. So there is always some risk of breaking things. It is your responsibility to carefully test your obfuscated script to see if it runs as intended. While obfuscation generally is a solid technology, never assume that obfuscating code will always work right.
If you checked “Create Obfuscation Table”, another script is generated. It defines two hashtables with the obfuscated names for variables and functions. Keep it safe. It can help you understand error reports issued by the users of an obfuscated script.
Always remember: Never obfuscate scripts that you want to publicly share with others. There is no point. Obfuscation is useful for scenarios where you want to protect your script logic, and where the script is not intended to be viewed, serviced, or otherwise touched by anyone.