amidaware / community-scripts

A curated list of powershell, python, and batch scripts for use in TacticalRMM or anywhere!
MIT License
122 stars 84 forks source link

Adding script template #164

Closed silversword411 closed 1 year ago

silversword411 commented 1 year ago

@NiceGuyIT Whatcha think about this for a template starter for PS...what other things might be missing?

dinger1986 commented 1 year ago

whys it got write-host and write-output? Whats the template to achieve? If its for someone to build scripts from then worth having it checking the event viewer and some other bits and pieces

silversword411 commented 1 year ago

Whats the template to achieve

I've got so many little scripts with missing check-bits everywhere I'm really trying to have a "start with this" so it'll be a pattern to use for all scripts (and I'll be slowly updating the library to follow the standards)

https://docs.tacticalrmm.com/contributing_community_scripts/#good-habits I'll be updating this as I go once this template has all the missing bits.

Not all the sections are needed for all scripts, but want a copy/paste for "standard" check stuff...where you can delete un-needed stuff. I keep forgetting which scripts have a good "do it this way for xyz task"

  1. RunAsUser...not always needed...but you need to make sure it's init'd if you're going to use it (can't use the native TRMM one when you have HKLM and HKCU registry entries to work with...for example)
  2. Making sure registry keys are there....setting reg keys with ps are a PITA, because if the keys don't exist, you're going to get an error, this simplifies. You have a function...just set all the key path and desired value and off she goes. etc.