Monthly Archive

Categories

Common parameters

I’ve been looking at the get-diskfreespace function over a number of posts. We’ve been looking a mixture of turning it into a production script and adding the advanced functionality from PowerShell v2.  In this post http://richardsiddaway.spaces.live.com/default.aspx?_c01_BlogPart=blogentry&_c=BlogPart&handle=cns!43CFA46A74CF3E96!2005 we added the

[CmdletBinding()] parameter

As soon as we add this parameter we get a whole bunch of functionality for free.  Our original function had a single parameter for the comptuer name – we now have a whole bunch of them

Get-Command get-diskfreespace | select parametersets

{ [[-computer] ] [-Verbose] [-Debug] [-ErrorAction ] [-WarningAction ] [-ErrorVariable ] [-WarningVariable ]

[-OutVariable ] [-OutBuffer ] }

These are the standard common parameters that we expect to see with any cmdlet.

Next we’ll  look at how we use some of them

 

Leave a Reply