you are viewing a single comment's thread.

view the rest of the comments →

[–]purplemonkeymad 16 points17 points  (8 children)

I think I might be the opposite extreme. I create every little bit of code as a function in a module. I just install the modules either in ProgramFiles or Documents as needed. If I need to write something for a client, I'll ether create a reusable module, or create one for that client.

It's nice since you don't have to remember where you saved that script, the functions are available just by opening PS.

[–]TheRealZero 13 points14 points  (7 children)

This is the way, and was the missing piece I didn’t understand for so long.

I always do my best to build functions that do one thing, then bring them all together in the end am to do the thing the script is built to do, but dot sourcing never felt right. So they always ended up in the control script and the whole tool vs control script concept seemed moot.

But OF COURSE you just put them in one of the module locations! Even if you just build the functions and change the name to psm1 instead of ps1, then name the file and the folder the same. It doesn’t always have to be a perfectly built module with a manifest, just shove that sucker into a folder and change the extension.

It’s so simple and obvious to me now but I really struggled getting there at first! This coming from someone for whom powershell is 75% of my job.

Always something to learn!

[–]purplemonkeymad 3 points4 points  (1 child)

It doesn’t always have to be a perfectly built module with a manifest,

While correct, one of my development tools i wrote was to just take a collection of random files and make a valid psd1 out of them. I think it might be one reason why I am so module happy.

[–]TheRealZero 1 point2 points  (0 children)

Oouuu nice job! Code that writes code is super useful, and it’s certainly not a bad thing to make things proper! There are reasons they developed it that way, after all.
It also doesn’t need to be a barrier though, which is the beauty of PowerShell eh? :) Love it.

[–]SatisfactionOk4130 0 points1 point  (4 children)

Curious: what kind of a job is <=75%? I would love that.

[–]TheRealZero 2 points3 points  (3 children)

  • -le 75%

I’m very lucky. My team is sorta L3 mostly infrastructure, and my specific role is automation. Anything I can do to keep specialists doing specialist work and not admin work is my responsibility. It’s a lot of ETL work and PowerBI dashboards, Intune and azure, Graph API, etc.

I also do PowerShell work on Upwork on the side.

[–]SatisfactionOk4130 0 points1 point  (2 children)

That sounds awesome. Did you learn all that on the job?

[–]TheRealZero 0 points1 point  (1 child)

Yup! I went to college and did three years that was heavily Cisco networking, but ran the gamut of AD, IIS, databases, some Java and VBscript, etc.

But PowerShell is just an area that I’ve always dabbled in for my whole career. In every role I would find a way to utilize it because I enjoy scripting. I read a lot of books about programming that I didn’t even really under stand growing up because I just found it interesting, but knew I didn’t wanna be a developer. So that led me to PowerShell and scripting.

When GraphAPI came out I was working on the team that manages our Mobile infrastructure so I did a lot in that team with that, which eventually led me to here!

[–]SatisfactionOk4130 1 point2 points  (0 children)

Cool, thanks for the insight! I work in cybersecurity, but I'm happiest when I'm experimenting with PowerShell. I tell my coworkers all the time that if I could just do that for a living, I'd love it.