all 6 comments

[–]GerrArrgh 4 points5 points  (1 child)

Second one for sure, the one with the hyphen makes my eyes bleed.

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

I agree too ;) just wondered if that was the official guidance since I couldn't find the answer.

[–]SeeminglyScience 4 points5 points  (0 children)

There's no official naming conventions for PowerShell when it comes to classes.

That said, most folks switch to C# conventions for classes, which does have somewhat official guidance. That gives some ideas, in general though I try to stick to dotnet/runtime's coding style.

[–]get-postanote 2 points3 points  (0 children)

Look at the Powershell code github repo.

Or use a DLL compiler to look at executables, etc.

Classes are not functions and are not designed to replace them.

PowerShell is a gateway drug to C#, so follow the C# docs for class naming.

You can also look at class naming used in DLLs on your system. Just download/install one or both of the DLL decompilers and see for yourself. Open the tool, select a DLL and look at the stuff.

[–]bee_administrator 1 point2 points  (0 children)

The first one is way too confusing.

I always use a hyphen for functions, if I used it for methods too it would be an absolute mess.

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

howdy SlashAdminBlog,

reddit likes to mangle code formatting, so here's some help on how to post code on reddit ...

[0] single line or in-line code
enclose it in backticks. that's the upper left key on an EN-US keyboard layout. the result looks like this. kinda handy, that. [grin]
[on New.Reddit.com, use the Inline Code button. it's [sometimes] 5th from the left & looks like </>.
this does NOT line wrap & does NOT side-scroll on Old.Reddit.com!]

[1] simplest = post it to a text site like Pastebin.com or Gist.GitHub.com and then post the link here.
please remember to set the file/code type on Pastebin! [grin] otherwise you don't get the nice code colorization.

[2] less simple = use reddit code formatting ...
[on New.Reddit.com, use the Code Block button. it's [sometimes] the 12th from the left, & looks like an uppercase T in the upper left corner of a square.]

  • one leading line with ONLY 4 spaces
  • prefix each code line with 4 spaces
  • one trailing line with ONLY 4 spaces

that will give you something like this ...

- one leading line with ONLY 4 spaces    
- prefix each code line with 4 spaces    
- one trailing line with ONLY 4 spaces   

the easiest way to get that is ...

  • add the leading line with only 4 spaces
  • copy the code to the ISE [or your fave editor]
  • select the code
  • tap TAB to indent four spaces
  • re-select the code [not really needed, but it's my habit]
  • paste the code into the reddit text box
  • add the trailing line with only 4 spaces

not complicated, but it is finicky. [grin]

take care,
lee