Tag Archives: Advanced Functions

Advancing the Function

AdvFunctionRecently I had to grab some general info on a group of VMs in a particular folder within vSphere.  Typical stuff like, Guest OS, # vCPUs, RAM, Disk, etc. I looked around my scripts folder as I was sure I had written a small script to accomplish this task previously but came up empty. No problem, I’ll just whip something up I thought. Then my mind starts racing, will the script output to csv? html? Excel? Word? I could include all options (and code) and let the user choose? What parameters will I need and how will I validate them? This script was getting cumbersome already and I hadn’t even thought about the simple info I needed to query. Then it dawned on me…all I needed was the data. I decided to strip the function down to simply gathering the information I needed. If I wrote a proper advanced function, then I could just return the gathered objects down the pipeline and from there format the output as needed.

Simply put, an advanced function acts very much like a standard cmdlet.

Continue reading