Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recommendations Following PowerShell Best Practices #8

Open
darkoperator opened this issue Aug 10, 2015 · 4 comments
Open

Recommendations Following PowerShell Best Practices #8

darkoperator opened this issue Aug 10, 2015 · 4 comments

Comments

@darkoperator
Copy link

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 :)

@Yoshi325
Copy link

@secabstraction Some of that might have something to do with trying to maintain backwards compatibility with previous versions of PowerShell.

@kjacobsen
Copy link
Contributor

Happy to lend a hand/check over things if you want.

Kieran Jacobsen


From: Jesse Davis [email protected]
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.

@besimorhino
Copy link
Owner

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 [email protected]
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).

@secabstraction
Copy link

I did a complete re-write. Should be much easier to follow now. https://github.com/secabstraction/PowerCat

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants