How to Cleanup Proprietary PowerShell Scripts to Share With the Community

Adam Bertram
4 min readJul 1, 2019

Before sharing code with the external world, there are a few essential questions to consider. Involvement in some kind of technical community is a beautiful thing. Not only do you contribute your knowledge to others, but you also gain knowledge and make yourself known, which could lead to other opportunities as well! I cannot recommend enough how important it is to be involved in some kind of technical community.

However, when it comes to sharing code in a community, things can sometimes get hairy. Some companies frown upon sharing for fear of exposing the company’s intellectual property or inadvertent exposure of internal details. These are valid concerns, but if your company does allow you to share, it is important to be diligent. You must ensure that any company-specific information is removed from your code before exposing it to the outside world.

There are a few questions you should ask yourself before hitting the publish button to share code (PowerShell scripts in this case) with the world outside of your company.

  1. Is my company name referenced anywhere in the script?
  2. Is any company-specific project name, department, etc. mentioned in the script?
  3. Is the script referencing any internal function or library that you won’t be sharing?
  4. Does the script represent any company's intellectual property (IP)?

Some of these questions are more complicated to answer than others. If you’re ever unsure if you can share a particular script, it’s always wise to consult with your manager or your legal team to ensure all is well.

Answering questions 1–3 can be done by looking at your code. It’s possible to manually verify each of these items by reading through your code, doing lots of find/replace actions on strings like your company name, departments, names, etc. and checking each function reference to ensure it’s not calling an internal module. This is but it sucks. I’ve been there many times, and it’s a task that has prevented me from sharing a lot of great work just because of the effort it takes to share it.

It is sometimes just too troublesome to clean up your code to make it “shareable.” Instead, you just…



Adam Bertram

A 20-year veteran of IT, crypto geek, content creator, consultant and overall problem solver.