This is part 4, the last and final post covering what we discussed at VMworld in the PowerCLI group discussion.
As always thanks goes out to Nigel Boulton who’s blog can be found here for helping me out taking such great notes.
The other posts in this series can be found below:
- Getting Started with PowerCLI
- PowerCLI Resources
- Launching and using PowerCLI
- Advanced tools and scripting
- Onyx – Check it out! this is a great “man in the middle” tool which sits in between the vCenter Client and the vCenter server and captures any actions you do in the client and converts it into PowerCLI code, but go careful, if I create a new VM it will not give me a nice New-VM cmdlet, it will give me the raw .net object code for creating the VM with specific code for only that VM, read more here but use it, its handy for finding out how to do something without knowing the SDK.
- Get-View cmdlet and .Extensiondata property, these are for accessing the raw view of the vSphere API, it ill allow you to do things faster (but harder looking code) and also access the parts of the API not yet abstracted into a fully formatted cmdlet by VMware, check out the numerous examples on the internet and learn how to use these. Advanced PowerCLI users only!
- PrimalForms Community edition (free) and PowerShell studio ($$$) are great tools for creating forms based scripts and allowing you to pass off a nice GUI on top of your existing script to others who may not want to launch the code, check out a simple example here.
- Get-Member cmdlet, this is great for looking inside the PowerShell objects and seeing what types the objects are, what properties exist and what methods exist.
- Another trick you can use to view properties, and not just the root level properties is the Format-Custom –Depth trick in PowerShell, for example: “Get-VM | Format-Custom –Depth 3”. This will give you a list of the properties 3 levels deep which can be useful for finding those nested properties.
- Use the Variables pain in PowerGUI, put your VM in a variable and then click the + to expand the object, this is great for browsing the object and its property names and values in an easy to view way, you can then relate it back to your script after you have found the property you want with a calculated property.
I welcome your feedback on a tool that let’s you allow non-administrators to safely run your PowerCLI and PowerShell scripts from a Web interface, using role based access control. It’s called System Frontier. It’s not free, but is very affordable for an enterprise class solution.
The user doesn’t have to know how the script works or have any admin rights on the target server(s). All output is captured and stored in SQL so you can easily report on who ran the task and what the result was.