Software Uninstall Automation [Part 3/3]


  • Add function information
  • Build the process
  • Full script
  • See it in action
  • Conclusion

This is the last part of this article, be sure to see the part 1/3 and part 2/3 if you didn’t yet!

Add function information

Powershell functions are blocks of code inside of a script for easy re-use, we can use them like we use cmdlets, we can set it’s own parameters and much more, we can even add information in it by using a comment block () .

 

 

 

All these informations can be accessed by using the Get-Help cmdlet:


Build the process

Building a process it’s more about debuggin it than just running it (the uninstallation in this case), we can’t know if a target is offline, or maybe the target doesn’t even have the software to be uninstalled, or maybe a key can be different from the collected key, like version key!

So, we need to imagine those errors possibilities and turn them into expected exits, and of course we also want to know if the software has been uninstalled and throw a success exit for that.

Follow the comments in the script below:

 


Full script

Finally it’s time to put it all together!

 

 


See it in action

In the animation below, I have tried first a software name that returns more than one object, that’s why the script stops since we want to remove only one specific software, then I change to another software name which returns only one object, then the script proceed asking for a computer list file, I select mine, which has only one name ‘ITFSCCM01’ (My lab has only two VM’s), The script first test the connection with ITFSCCM01, then search for a match of the classkey we have captured before, then if all those steps returns TRUE, the software is finally uninstalled, if I had more names in my computer list the script would proceed into these steps until the last one.

Conclusion

And this ends my very first article here! I’m really enjoying and trying to bring my best to the community.
I invite you to follow me on twitter, github, linkedin and facebook, please if you liked this article share it with your colleagues!

If you have any doubt or something went wrong, don’t hesitate to ask me help! 🙂


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 )

w

Connecting to %s

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