PowerCLI In The Enterprise: Breaking The Magician’s Code & Function Templates

At today’s #UKVMUG I presented on the topic: PowerCLI In The Enterprise: Breaking The Magician’s Code. Below are the slides from the session:

During the session I discussed breaking your PowerShell code down into functions and modules. To aid with this I am posting the 6 function templates I use which cover many of the typical scenarios I write a function for and enable the rapid creation of these functions since much of the code is typically repeated. These are:

  • Get-Something
  • Set-Something
  • Get-VMSomething
  • Set-VMSomething
  • Get-VMHostSomething
  • Set-VMHostSomething

and can be downloaded below. I hope you find them useful :-)


I am also posting an XML based snippets file by which you can add all of the above functions to your PowerShell ISE User-Defined Snippets. Simply copy this file to your $home\Documents\WindowsPowerShell\Snippets folder (you may need to create this folder since it is not there by default). Rather than then having to copy and paste one of these template functions, you can insert them via Ctrl-J. This post will explain to you more how to use snippets in the ISE.



2 thoughts on “PowerCLI In The Enterprise: Breaking The Magician’s Code & Function Templates

  1. Great session, took me back 20 years when I used to do some Lisp programing for AutoCAD. Reinforcing the KISS principle with simple modular reusable code. Another kick start to get into some level of automation. For me the best session of the day, after Joe and Greg. Thanks
    Mr Zero Automation.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>