r/PowerShell • • Oct 09 '19

My IT Tool

Figured I'd share my little program as well. Been working on this on and off for about 6 months now. Just started getting into Powershell. Some key features are a security check the second the program is ran. If the user is not part of the proper OU, it will display an error message, email the IT dept with their username and computer, and then close the program. Just to make sure only IT people can use it. Every action is also logged to a central server Event Viewer.

Program screenshots: https://imgur.com/a/qsjk4ek

Code: https://pastebin.com/0FmdSaRF

I know I can clean it up some and probably stream line some stuff but, again, I've only been using Powershell since the beginning of the year basically and I have no real other programming experience prior. I made this to really just make my job a little easier and quicker. I started this in Powershell Studio trial with the form and tabs. Pulled that code and have been using ISE ever since. Apparently Studio is just too expensive for my company but oh well.

EDIT: GOLD?! Wow, my first! Thank you internet stranger! I also wanted to thank everyone on here who helped me the times I came looking for help with certain aspects of this thing. I really appreciate it. And thanks to everyone on this post for tips and suggestions, I will definitely look into them all. Always looking to improve.

172 Upvotes

62 comments sorted by

View all comments

6

u/edelwater Oct 09 '19

nice! for config instead in the file itself as parameters you could use an ini file and put there the variables: https://github.com/projectje/powershell_scripts_various/blob/master/Config/Config.psm1

For reading / writing eventlog you could move code to a module e.g. https://github.com/projectje/powershell_scripts_various/blob/master/EventLog/EventLog.psm1

once you have everything in modules you can keep the main script very small with only a couple of variables and then leverage on the modules.

3

u/bajinabass Oct 09 '19

Oh wow! I will check both of those out. Thanks for those links.

2

u/edelwater Oct 09 '19

also: https://www.powershellmagazine.com/2014/04/18/automatic-remote-desktop-connection/ (windows credential manager for storing credentials instead of c:\PW.txt ) (or search this reddit for cmdkey)

2

u/bajinabass Oct 09 '19

I will check that out. Thanks!