Options

Good method of organizing your scripts/code

N2ITN2IT Inactive Imported Users Posts: 7,483 ■■■■■■■■■■
I was wondering if the forum could recommend a method or tool (both potentially) to save scripts for future use.

Example PowerShell, VBA, etc. Something that I could have one set file organized enough to go back through with little down time. I understand the concept of writing in instructions into the script so it's easy to see what it is automating or "doing".

I'm not a developer by trade so any experience or useful ideas would be greatly appreciated.

Comments

  • Options
    SteveO86SteveO86 Member Posts: 1,423
    When I did desktop support years ago, I'd write VBS scripts to automate as much as I could.

    I just saved each of those scripts to a file and created a naming convention for each file. Not sure if powershell is the same way. After I while though the list did start adding up, but it was such repetitious work I just navigated to the that folder using the keyboard used the keyboard letters to get the script I needed.
    My Networking blog
    Latest blog post: Let's review EIGRP Named Mode
    Currently Studying: CCNP: Wireless - IUWMS
  • Options
    NetworkVeteranNetworkVeteran Member Posts: 2,338 ■■■■■■■■□□
    N2IT wrote: »
    I was wondering if the forum could recommend a method or tool (both potentially) to save scripts for future use.
    Source code management is important to anyone who regularly develops code. You don't just want a way to save code snippet A, but also code snippet A v1.0 vs. code snippet A v2.0! This comes in handy when you discover your new code has a bug and you want to roll-back or figure out precisely what was changed to narrow down anissue.

    The best tool is often highly dependent on your environment. However, there's a tool that's free, often pre-installed on Mac and Linux boxes, simple to start using, and solid enough to be used by large corporations called "CVS". It's been my go-to when I've pick-up one-off projects that don't justify a more sophisticated versioning system.

    http://ximbiot.com/cvs/manual/cvs-1.11.23/cvs.html
  • Options
    wes allenwes allen Member Posts: 540 ■■■■■□□□□□
    Maybe Evernote?
  • Options
    NotHackingYouNotHackingYou Member Posts: 1,460 ■■■■■■■■□□
    I like oneNote or I just save them in their native format, well named in a directory structure.
    When you go the extra mile, there's no traffic.
  • Options
    paul78paul78 Member Posts: 3,016 ■■■■■■■■■■
    A source-code management system like NetworkVeteran suggest is probably a good way to go. There are a few systems which can integrate into CVS. But the learning curve for CVS can be steep. A lot of teams and even one-person shops also use Subversion or SVN. SVN was designed as a replacement to CVS and may be easier if you simply have a few code projects to organize and share.

    If you are using Windows - I like TorroiseSVN which is very easy to get up and running - TortoiseSVN
  • Options
    CodeBloxCodeBlox Member Posts: 1,363 ■■■■□□□□□□
    My vote goes to SVN. It's also available on Windows and it integrates with explorer.
    Currently reading: Network Warrior, Unix Network Programming by Richard Stevens
  • Options
    ptilsenptilsen Member Posts: 2,835 ■■■■■■■■■■
    Definitely need a source control system. I implemented Wandisco UberSVN for a client a couple years ago, It was fairly easy to implement and had some nice features, meant to be more of a commercial solution, with support avalable and everything. There are other distributions as well.

    I was looking into this recently for the same reason, and I came to the conclusion that Team Foundation Server might be the best for working with PowerShell specifically, but it's not free. It is if you have a Technet subscription or the right type of agreement with MS. Here's a comparison between TFS and Tortoise SVN, a popular SVN client. I've also read Mercurial is good. I haven't worked with any of them enough to make a specific recommendation or really appreciate the difference.

    Let us know what you end up with and how it goes. I am definitely planning on implementing one soon, but I'm definitely having a tough time weighing my options. However, I would probably have gone with TFS already if I could get the okay from my boss.
    Working B.S., Computer Science
    Complete: 55/120 credits SPAN 201, LIT 100, ETHS 200, AP Lang, MATH 120, WRIT 231, ICS 140, MATH 215, ECON 202, ECON 201, ICS 141, MATH 210, LING 111, ICS 240
    In progress: CLEP US GOV,
    Next up: MATH 211, ECON 352, ICS 340
  • Options
    Bender RodriguezBender Rodriguez Member Posts: 12 ■□□□□□□□□□
    I use one note quite a lot. I didn't like it at first, but it really helps me organize scripts (and complete router/switch configs) by year and by client. I would give it a chance.
  • Options
    N2ITN2IT Inactive Imported Users Posts: 7,483 ■■■■■■■■■■
    Thanks for providing a lot of solutions. I'll implement a quick one now just to maintain what I have created and then think about transitioning to a more scalable solution.
  • Options
    ClaymooreClaymoore Member Posts: 1,637
    I used to just **** them all in a folder and rely on my naming convention to organize them, but that wasn't working for me any more. One, I now have too many scripts. Two, I don't really need to run a particular script again. What I want to do is borrow code from previous scripts to create new ones specific for my current client. OneNote helps me do that. I always have it open, so all I have to do is flip over to my scripts tab and grab the code I need. I don't need anything as fancy as source control and versioning that would require something like TFS.
  • Options
    undomielundomiel Member Posts: 2,818
    I had started thinking about this lately as I was finding myself taking longer and longer to search through all of my script folders for scripts to take chunks from. OneNote sounds like an excellent idea to me. Thanks for bringing the topic up. I probably would have ended up tossing everything into TortoiseSVN otherwise.
    Jumping on the IT blogging band wagon -- http://www.jefferyland.com/
  • Options
    blargoeblargoe Member Posts: 4,174 ■■■■■■■■■□
    I may give one note a shot myself. I was just pondering this same issue last week.
    IT guy since 12/00

    Recent: 11/2019 - RHCSA (RHEL 7); 2/2019 - Updated VCP to 6.5 (just a few days before VMware discontinued the re-cert policy...)
    Working on: RHCE/Ansible
    Future: Probably continued Red Hat Immersion, Possibly VCAP Design, or maybe a completely different path. Depends on job demands...
Sign In or Register to comment.