PowerShell Snippets

This week I’ve been watching the recent Microsoft Virtual Academy on Advanced Desired State Configuration and Custom Resources.

It’s interesting to see what Microsoft are doing in this space given the competition has been around for years. DSC is in its infancy and there are still issues that need to be ironed out. Some of the demos in the MVA didn’t work and it wasn’t straightforward to troubleshoot them. However as DSC scripts are PowerShell based the learning curve for existing Windows administrators is much lower than with Chef or Puppet. So I think it does have a place and is something I’m excited about looking at in the future.

One of the presenters was the inventor of PowerShell, Jeffrey Snover. As a result I got some new PowerShell tips!

Wildcards in Cmdlet Names

Can’t completely remember the name of the cmdlet you want to use? It’s tough these days – for instance some of the Azure cmdlets are really long and difficult to memorise. Just use a wildcard in the cmdlet name, press tab and PowerShell will autocomplete with matching cmdlet names. Continue to press tab to cycle through the options.

Show-Object

It’s difficult to view the properties of complex objects in PowerShell. Yes there is Get-Member but it takes quite a bit of work to view everything. Lee Holmes, author of several PowerShell books has written a neat cmdlet called Show-Object which you pipe an object to. It then brings up a window with all the properties in a tree format. It even provides the expression to access that property in your PowerShell scripts.

2015-04-06_10-36-48

This entry was posted in PowerShell, Scripting. Bookmark the permalink.

Leave a Reply

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