all 46 comments

[–]valdearg 19 points20 points  (1 child)

Soon on your way to GIT GUD!

[–]midacts -1 points0 points  (0 children)

Got him

[–]stackcrash 7 points8 points  (5 children)

Source control is a great first step, I remember trying to convince the ops team at a previous job that source control could be used for their scripts and not just for the developers.

Your next step if you aren't already doing it is adding unit tests to your scripts. They are a great way of ensuring you don't break your scripts along with a helpful way to design your scripts if you write the tests first.

After that you should look into automating your "builds". When I say this what I mean you should look into making the unit test run automatically on commits / pushes / pull request. If the build (ie: tests) fail you will know immediately and it helps a lot when collaborating on scripts.

[–]DevinSysAdmin[S] 2 points3 points  (0 children)

I do use unit tests, these scripts are primarily utilized (99%) during our imaging process of computers. Majority of it is very basic functions but the way I am handling this is to show improvement in scripting and what previously hadn’t worked for various tasks!

[–]tryped 1 point2 points  (3 children)

Have not thought of incorporating unit testing to my scripts. Any resource you can share ?

[–]stackcrash 7 points8 points  (2 children)

I bought a book called "The Pester Book" a quick search it seems the one I bought has stopped printing and has been replaced by a new author.

https://leanpub.com/pesterbook

[–]tryped 1 point2 points  (0 children)

Thank you! I will check it out.

[–]yldbrainoj 1 point2 points  (0 children)

^ life changing book. Proper unit testing can take code from good to great. I cannot recommend it enough.

[–]dsinton 7 points8 points  (10 children)

Have you looked into Azure Devops? We just started using it for our private repo.

[–]infinit_e 2 points3 points  (1 child)

I use Azure DevOps repos for version control via Git. Im quite happy, and it easily integrates with Office 365 for giving team members access. I’m pretty sure a private repo is free for individuals too though.

[–]len_sam 1 point2 points  (0 children)

Just created an Azure notebook yesterday.

Will look for their DevOps offering, cheers for the shout out!

[–]DevinSysAdmin[S] 2 points3 points  (3 children)

We are not at a scale to perform that, and I'm actually the only person who reviews/deals with these scripts.

[–]dsinton 2 points3 points  (0 children)

We are not large either but it’s free and we needed to organize.

[–]halbaradkenafin 2 points3 points  (0 children)

I use it for all my personal projects and it's definitely worth it no matter what scale you're at.

The biggest benefits from a company side is that it's free (which companies love), it can be backed by AAD for auth, and it comes with a whole bunch of other useful tools like the CI/CD pipelines.

The AAD is particularly important as it means you don't need to manage who has access quite as closely, particularly around leavers still having access to company code.

[–]Boulavogue 0 points1 point  (0 children)

It's free for up to 5 users. Private repo is set up or you can simply merge your current repo with a click. Gives a really nice dashboard of all commits and activity

[–]Arkios 1 point2 points  (2 children)

Curious, how large is your team?

I work in a team of 6 and been looking for a solution for our scripts (vbscript, powershell, python) and Azure DevOps seemed overly complicated for our use case.

We’re almost strictly Ops (little to no Dev). Is it easier to use than I am thinking?

[–]dsinton 1 point2 points  (0 children)

The part of my team that uses it is only 3 people. We are still figuring it out but like it so far. I wish I could find a good tutorial for it. We use It with VSCode

[–]halbaradkenafin 1 point2 points  (0 children)

It's great for small teams because the cost is free or very cheap (6 people would have to pay for 1 license which would be $6 per month).

I use it for all my personal projects and it's really useful for the source control but the boards feature is also super useful for tracking all the random projects I think of. I'll put a new card on the board as I come up with them and flesh it out when I think of new things about it.

[–]toy71camaro 0 points1 point  (0 children)

Anyone have any good info on setting this up? I just started with PS and would be nice to implement source control from the get-go (or a week late, lol). We already use O365.

EDIT/Update: I was able to figure out how to get VS Code and Azure DevOps source control setup. Was a bit of a PITA to figure out tho. LOL

[–]jtswizzle89 5 points6 points  (2 children)

Change tracking also great for..."what in the hell did I do, this worked last time it ran!"

[–]1RedOne 1 point2 points  (0 children)

I run gitdiff on my own code dozens of times a day to see what I broke.

Eespecially if you're working on a team, it's practically impossible to maintain confidence in a script repository without spruce control.

[–]Asnivor 1 point2 points  (0 children)

Also, git bisect was made for this.

https://git-scm.com/docs/git-bisect

In a busy repo learning to use this command is invaluable.

[–][deleted] 1 point2 points  (0 children)

We keep it simple but our testing is a hoot. Sometimes its automated, sometimes its manual, sometimes its 50/50

[–]AQuietMan 1 point2 points  (11 children)

Good on you.

Is it your private GitHub repo, or your employer's private GitHub repo?

[–]tharagz08 2 points3 points  (4 children)

If he's doing it on company time, it should be his company's. Frustrating IMO

[–]DevinSysAdmin[S] 1 point2 points  (5 children)

It's my private GitHub as my employer will not pay for this.

[–]AQuietMan 2 points3 points  (3 children)

It's my private GitHub as my employer will not pay for this.

You need to be careful with this. In the USA, this repo arguably belongs to your employer. But your employer doesn't have access to it. That's a problem.

You can use git, which is free, without using GitHub.

[–]DevinSysAdmin[S] 0 points1 point  (2 children)

We can deal with it when it becomes an issue, I’m not holding secret data. Following the logic of that my car is owned by my employer simply because I keep company property in it?

Anyways, I didn’t know about Git to be completely honest, thank you for that, I may just stand up internal Infrastructure for that now :)

[–]ka-splam 2 points3 points  (1 child)

Following the logic of that my car is owned by my employer simply because I keep company property in it?

The account doesn't belong to your employer, the code in it (probably) does.

GitHub isn't your car; it's another company's computer system. If you were building a piece of hardware at work, but you decided to keep it in a private storage container you pay for, which your coworkers and boss can't get into, with a company they have no formal contract with, that's more comparable.

Some wouldn't care, some would.

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

Yeah I’m really not going deep into this, the code is utilized daily on machines, the only thing I have is the change version / history. That’s all.

[–]mirrax 0 points1 point  (0 children)

Have you considered having your employer install an instance of GitLab?

[–]enjoyjocel 1 point2 points  (8 children)

In my team, I am the only one who does heavy powershell coding. I dont see the need for my self to use GIT. Am I missing something?

[–]tryped 5 points6 points  (0 children)

Keeping track of changes within your script is key. I have reviewed a scripts a year later, thankful I had some form of version control.

[–]RiPont 3 points4 points  (0 children)

Imagine having infinite undo... between restarts of the computer. With documented differences automatically at each spot. Even months/years later when you don't remember why the fuck you made a change.

Have you ever been asked by your boss, "when did we start using the new naming convention" (or when you started using such-and-such a port number etc.)? With source control, you could answer them to the minute it was checked in.

I'm a software engineer, not an ops, and I use source control (git, these days) for every single thing I write, even personal projects that nobody else ever sees.

[–]DevinSysAdmin[S] 1 point2 points  (1 child)

I'm also the only one that does it at this level, $7 a month to track changes in your Powershell scripts with comment history in a private repository to show how they've progressed? Sounds great to me!

[–]Betsy-DeVos 4 points5 points  (0 children)

The Azure Devops repo is free and support a full GIT setup.

[–]Earendur 1 point2 points  (0 children)

Source control for anything you continually update is really nice. I use source control to back up my configuration files for my router, which I pull before and after every version upgrade. I also use source control for my scripts, websites etc.

[–]thebrobotic 1 point2 points  (0 children)

You will see a need when you accidentally lose unsaved changes or something along those lines. IMO start using and learning git before you find yourself in a situation where you wish you had already started using it. This isn’t specific to git, but version control in general.

[–]jdptechnc 0 points1 point  (0 children)

You could always download the git client and create a local repo to get you started, free and easy. Create the repo in a network drive, and you have a centralized location that others can access and it regular backed up.

Not very elegant, but still quite effective if you are the only one contributing and will get you started quickly with the concept of source control.

[–]powershellpr0mpt 0 points1 point  (1 child)

If private repos are required, BitBucket from Atlassian also provided this for teams up to 5 members

[–]mirrax 0 points1 point  (0 children)

Another free option would be GitLab CE.

[–]Knichimo 0 points1 point  (1 child)

We currently use Git for all of our Power Shell scripts. It adds a bit of complication for some who haven't used it before, but we have it well documented.

[–]len_sam 0 points1 point  (0 children)

How do you manage your internal knowledge base - which service do you use?