r/PowerShell • • Apr 04 '26

Powershell Noob

Hey all

I’m a slight newbie and landed a JR infrastructure engineer role that includes looking after cloud environments, patching software and machines.

Is there any advice where I could get into learning more powershell scripting or and decent YouTube courses I could follow

Any help is appreciated

20 Upvotes

49 comments sorted by

View all comments

Show parent comment

2

u/xXFl1ppyXx Apr 06 '26

i really don't want to rain on your parade but i find that hard to read, let alone understand what it does without reading at least half of the code. When Start-Process popped up i could make an educated guess.

Furthermore i really wouldn't want to start anything that's simply named Robocopy without skimming through the code to check if it's not /MIR something the wrong way and i've guessed the use of the function / script wrong

In fact, this example is (to me at least) a textbook example where comments really would make life easier

1

u/TofuBug40 Apr 06 '26

Comments on reddit are really hard to give a proper visualization of code like you would see in a proper editor. I do acknowledge my style does fly in the face of most styling guidelines it takes a day or so to acclimate but i'm dealing with other people who barely have the time nor the want to try and remember and learn an entire style guideline so we have some kind of consistency. So I made the style guide as simple as possible none of this well sometimes an if is one line so you can make it a one liner or sometimes no parameters so you can not wrap things none of that. The entire styling guide is maybe one page.

  • Every Token gets its own line
  • Tabs Denote parent/child and block ending
  • ALWAYS splat cmdlets
  • Keep slats as close to cmdlets using it
  • CamelCase
  • Follow PowerShell approved Verbs

That's it and it literally covers everything you could ever do in PowerShell. Once they get it they don't have to remember anything else for styling

Not telling you how you are looking at it but most people tend to get stuck at first trying to take in the whole screen at once. The point is you can start anywhere at any line and you can see from the tabs what is a child or something what is a parent of something. You don't have to take it all in at once. You're not trying to parse over a long horizontal line of multiple commands trying to keep it all in frame especially when they scroll horizontally.

Say for instance you are trying to figure out what's going on to with the start process you jump right down to the start-process line (which i realized too late reddit is stripping the @ splats from the code block so it should have @ StartProcess after the cmdlet. Since they style keeps the hashtable for the splat right next to the cmdlet we can see exactly what it is doing and since each item gets its own line we can lock in on one of them, add one, remove one, without having to remember the ; and all kinds of other annoyances that come from trying to cram stuff onto single lines of code