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
I showed how to write an Advanced Function / Script cmdlet / thingy
Having stumbled over the post today I thought I better bring it up to date so rewrote the code as a PowerShell v2 advanced function
If you’ve looked at advanced functions this should be straight forward.
Define three parameters each of which is given a position. If the values are passed without the parameter name that is the order in which the data will be processed. Each parameter is given at least one alias and a help message. The value is also checked to make sure that it isn’t null or empty
The eventlog object is created and the message written. Because I used the [CmdletBinding()] attribute I can use –whatif as a parameter. The if statement allows the processing of -whatif
This code does exactly the same as the original but the syntax is up to date.
Not sure if the Write-Eventlog cmdlet was in the original CTP but don’t think it was which is why I used this example.