Recommendations Following PowerShell Best Practices
darkoperator opened this issue · 4 comments
Some recommendations in style and functionality
- PS functions follow the convention of ver-noun, this could be Invoke-PowerCat in the main function
- It is PS not Bash so help should be in comment based form so it is discoverable and parable by Get-Help and not use a -h/-help parameter (Run in a PowerShell console 'help about_Comment_Based_Help')
- The main function should be an advanced function with cmdletbinding so as to manage parameters properly (help about_Functions_CmdletBindingAttribute and help about_Functions_Advanced_Parameters)
- This is better suited as a module with a proper manifest where the main function is exported while the helper ones are hidden from the user so it can be used as a proper tool and allow for module autoloading, get-command discovery ..etc. (Look at help New-ModuleManifest -full)
- Parameter should be full named parameters and not single letters or be aliased as single letters, PowerShell behaves like Cisco IOS where for example -UDP can be -U or -UD as long as it is unique enough vs the other parameters.
The community and MS are working on a Style Guide and Best Practices guide https://github.com/PoshCode/PowerShellPracticeAndStyle I know I made the recommendations to the original author but since I see it is being maintained by others now I thought I would repeat them :)
@secabstraction Some of that might have something to do with trying to maintain backwards compatibility with previous versions of PowerShell.
Happy to lend a hand/check over things if you want.
Kieran Jacobsen
From: Jesse Davis notifications@github.com
Sent: Sunday, 13 September 2015 10:47 AM
To: besimorhino/powercat
Subject: Re: [powercat] Recommendations Following PowerShell Best Practices (#8)
I've started re-writing it, hopefully finish soon. Only made it through the first few lines, the netstat dependency and unnecessary parameter checking were the first things to go. Powershell has a lot of built-in features that are clearly unknown to the original author, no offense intended.
Reply to this email directly or view it on GitHubhttps://github.com//issues/8#issuecomment-139832598.
Awesome! Thanks so much! We'll take a look and start approving them. Due
to DerbyCon, it'll be sometime either then or the next few weeks.
Cheers
- Mick
On Sun, Sep 20, 2015 at 10:08 PM, Jesse Davis notifications@github.com
wrote:
some of my updates
https://github.com/secabstraction/powercat/blob/master/Invoke-PowerCat.ps1—
Reply to this email directly or view it on GitHub
#8 (comment).
I did a complete re-write. Should be much easier to follow now. https://github.com/secabstraction/PowerCat