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.