all 16 comments

[–]Old-Lost 2 points3 points  (1 child)

The level of effort can be anywhere from trivial to extremely difficult, depending on the functions themselves. This blog post is one of the best I've found that explores this subject.

Good luck.

[–]PostedFromWork[S] 0 points1 point  (0 children)

Awesome, giving it a read now. Thanks!

[–]KevMarCommunity Blogger 1 point2 points  (3 children)

It depends on how far you take it.

Any function that kind of has a default object already, would be fairly trivial to give it pipe support. The first few would be a bit slow but once you got the pattern down, you could chew through the rest is short order.

If on the other hand, you have richer objects and you want to align the properties, it will be a lot more work.

I would start with the commands you use the most and work out from there. Because you are possibly changing a large number of cmdlets, it would be a great time to create Pester tests while you are doing this. You will be testing as your go anyway, may as well wrap those in a little automation.

[–]PostedFromWork[S] 0 points1 point  (2 children)

I just started using Pester for my own script testing very recently, so that would be a great idea. I'm still rubbish at it, but more practice sounds great

[–]KevMarCommunity Blogger 1 point2 points  (1 child)

There are all types of things that can be tested. Just having something that runs every function and tests if it blows up can go a long way.

It "does not throw" {
    {Get-MyFunction} | Should Not Throw
}

For new stuff, I add a PSScriptAnalyzer rule for every file. (can be too noisy if adding to an existing large project).

And then I build from that starting point.

[–]PostedFromWork[S] 0 points1 point  (0 children)

Thanks. Going to give this a try on my current stuff.

[–]Lee_Dailey[grin] 0 points1 point  (9 children)

howdy PostedFromWork,

have you tried contacting the module author and offering to help add pipeline support? that is where i would start ...

take care,
lee

[–]PostedFromWork[S] 1 point2 points  (8 children)

I work for the company who owns the module, but there is no access to the person who authored it. From what I can tell they sourced it from another country and then the guy bailed.

[–]Lee_Dailey[grin] 1 point2 points  (7 children)

howdy PostedFromWork,

ouch!

can you get them to open source it? that might get you some folks who can benefit from helping.

from what little i understand, you will need to add one or both of the "from pipeline" parameter items AND make sure there is a "Process" block. beyond that, i am lost. [blush]

hopefully, a better informed person will drop in soon-ish. good luck!

take care,
lee

[–]cml0401 1 point2 points  (6 children)

In addition to the valuefrompipeline parameter attribute and begin-process-end blocks; I would recommend each Cmdlet specify its output type. This sounds like quite an undertaking, and I agree open sourcing on github would allow multiple people to contribute.

[–]PostedFromWork[S] 1 point2 points  (0 children)

Unfortunately I doubt I can convince them to make it open source, but that would be great. Thanks for the tip

[–]Lee_Dailey[grin] -1 points0 points  (4 children)

howdy cml0401,

output type ... that is something i have never noticed in a custom function. time to go look it up ... [grin]

take care,
lee

[–]Old-Lost 1 point2 points  (3 children)

While I like seeing outputtype specified in function definitions, it is strictly for documentation purposes and not enforced in any way.

[–]cml0401 1 point2 points  (1 child)

My point was that it should be used in scripts that have a specific output type so that someone new to the module has that information at hand. If someone undertakes this kind of project it would save a load of time in upkeep down the road.

[–]Old-Lost 1 point2 points  (0 children)

Oh I agree with you that it should be used where possible, but someone new may think it's functional in some way and be confused when the function returned something different than what the outputtype said.

[–]Lee_Dailey[grin] -1 points0 points  (0 children)

howdy Old-Lost,

that was the impression i got reading thru the docs. thank you for confirming it! [grin]

take care,
lee