Automating Daily Tasks
Most of us have daily, repetitive, mundane, and/or unwanted tasks in our lives that can be somewhat or entirely automated. Using a spreadsheet to track information on a daily basis? Automate it. Query…
AUTOMATION
Weston Wilson
9/26/20234 min read


Most of us have daily, repetitive, mundane, and/or unwanted tasks in our lives that can be somewhat or entirely automated. Using a spreadsheet to track information on a daily basis? Automate it. Querying devices to make sure everything is in compliance? Automate it. Most tools these days have an API (application programmable interface) that make it easy to create automation around tasks. Worst case scenario, you can connect to a website address and manually pull in the HTML elements you need.
Where to start
First, you’ll want to look at your tasks that are very repetitive. It’s a bonus if the job takes a long time to complete. Next, look through your organization’s policies and practices to make sure you won’t be violating any rules. Then you need to determine the best way to script out the automation. Some considerations should be
What kind of environment am I in - Mainly Windows machines, only Mac, a combination of everything, etc.?
If you’re mainly a Windows shop, PowerShell or bin scripts may be the best option.
Linux or Mac may mean shell scripts.
Python is a great option for scripting with tons of extensibility from PIP
How can I make this automation transferrable to others?
I have had some trouble in the past getting team members to set up and use automation with Python scripts when in a primarily Windows environment.
The easiest way to get the script transferred to others is to make it system native, like with PowerShell.
Otherwise, make sure to document how to install dependencies for others to follow.
The easier the install, the easier it is to have others use.


How can I make this extensible?
Make sure to include comments in the script. This makes it easy for others to review and edit the script for additional uses. It also helps you if it has been a while since you edited the script.
Making a GUI (graphical user interface) can make the script more complicated and have more abilities, but you can also accomplish more tasks with option inputs in a console.


How can I make sure this is secure?
Consider how the script could be abused or used to collect information you don’t intend.
When using an API, use API keys or other secure ways of transporting credentials.
If you have to use usernames and passwords, don’t store them inside the script… and make sure they’re masked (“********” instead of “password”) or encrypted in memory.
Use secure protocols if at all possible - think “S”… SFTP, HTTPS, SSH, LDAPS, etc.
Sanitize any inputs. This means if you’re expecting a string or a number, the input should be explicitly set as such.
number_input = int(input(“Enter the number of days: “)) #explicitly set this value as an integer value
But I’m not a developer
That’s ok! Take things slow and start simple. Test often when you get going. You can use various internet resources to learn basics of scripting languages, and use community forums for help afterwards. If you have a question on how to do something, it’s likely someone else has already asked the question, and it likely has an answer on a site like Stack Exchange or somewhere similar. Just use your favorite search engine and type in some keywords or questions. Most things are possible, so try to think of “how” something can be done instead if “if” it can it be done.
Resources I have found useful:
Codecademy - a free site to learn basics of coding in various languages. They have paid courses/subscriptions for reinforcement of concepts.
W3 Schools - a free site to learn web development fundamentals.
AutoHotKey - an easy-to-use tool for automating tasks and using keyboard shortcuts
So many blogs and step-by-step guides. There’s probably one that covers something similar to what you want to accomplish.
Most people are willing to share their code. Make sure you review code you find online before adding it to your script. Make sure there aren’t any suspicious commands.


Check out my GitHub repository for some example scripts, like whitelist_query_sanitized.py in the Python repository.
Examples
Here are some examples of automation scripts I have created to give you ideas to get started.
License count and scan status checks on a system for a daily review, piped into a tracking spreadsheet
Updating 50 Tenable sensor servers before and after a software update
Daily checks and remediation of Nessus agents which have not checked in for more than 2 weeks
Time card logging GUI tool
Website reputation lookup across multiple tools
Good luck and have fun with making your job and your life easier!