Browse by Tags

All Tags » Advanced Functions » PowerShell V2 (RSS)

Yes I’m sure

One of the great safety features of PowerShell are the –whatif and –confirm parameters on cmdlets. They can really be useful in preventing hideous, career limiting actions   We can create the same functionality on our advanced functions function...

Windows updates: 4 tidy up get-update

Looking at the get-update function we created earlier I wanted to tidy it up a bit. 001 002 003 004 005 006 007 008 009 010 011 012 013 014 015 016 017 018 019 020 021 022 023 024 025 026 027 028 029 030 031 032 033 function   get-update   ...

Advanced Function update

If you were around PowerShell back in November 2007 you might remember that the PowerShell v2 CTP was the new kid in town. One of really big things at the time was script cmdlets – that we now call Advanced Functions. Back in this post http://richardspowershellblog...

Advanced Function template

In this post I showed my Advanced Function template  http://msmvps.com/blogs/richardsiddaway/archive/2011/05/13/powershell-module-construction.aspx I’ve since modified it to add the parameter validation methods. I can never remember them all so decided...

Advanced Functions: part 3

Lets start looking at validation of parameter values. We have a few options to try   [ValidateCount(1,n)]    [ValidateLength(1,m)]    [ValidatePattern("[A-Z][A-Z]A-Z][0-9]")]    [ValidateRange(0,10)] ...

Typo

Thanks to Shay for pointing out some typos in my last post.  The correct bits are     [alias("alias_name")]     [datatype]     [AllowNull()]     [AllowEmptyString()]    ...

Advanced Functions part 2

I thought it would be worth while looking at the range of parameters we can use with our functions. We saw the mandatory parameter last time but that is just a starter. If we examine the range of parameters we see that there are some to control how we...

Advanced Functions part 1

Advanced functions are one of the major new features of PowerShell. They enable functions written in PowerShell to behave in the same way as cmdlets especially in the way they work on the pipeline. However when you look at the help files PS> get-help...