Skip to content

IT / AUTOMATION

Power Scripting

PowerShell scripts written to automate routine admin tasks: what each one handles and what it taught me.

SCRIPT TOOLKIT

A pair of PowerShell entry points that turn repeated setup and maintenance chores into short commands. Dev maps project names to their folders and launchers, while tools bundles the routine Windows checks, cleanup, and updates into one menu. Both exist for the same reason: to cut the path-and-flag memorization so I can actually remember commands.

PowerShell · DevTools

PS C:\Users\j_wil\Documents\DevTools> tools list

Commands:
  health           Full run: specs, services, uptime, latency, updates.
  check            Read-only health check (no update or cleanup).
  specs            Hardware, Windows version, and system state.
  services         Verify WinDefend and Spooler are running.
  uptime           Days since last boot.
  latency          Five pings to google.com.
  cleanup          Empty recycle bin and temp files older than 7 days.
  update-apps      winget upgrade --all.
  update-windows   Start a Windows Update scan.
  bios             Prompt, then reboot into firmware settings.

PS C:\Users\j_wil\Documents\DevTools> dev list

Apps:
  portfolio  F:\ReflexApp
  albion     D:\PythonProjects
  albioncli  D:\PythonProjects
Menu output from tools.ps1 and dev.ps1

dev — launch projects by short name

dev keeps an ordered table of local apps. Each entry stores the working directory, executable, and base arguments. Running dev <command> changes into the right folder, launches the app, and forwards any extra arguments to the target. The script checks that the executable exists, prints a usage list for dev list or an unknown name, and uses try/finally with Push-Location and Pop-Location so the shell always returns where it started.

tools — one maintenance menu

tools is a dispatcher built on an ordered command table: health, check, specs, services, uptime, latency, cleanup, update-apps, update-windows, bios, and a huge number of other commands not listed. Each command points at a function in various powershell scripts, and has matching help table generates the built-in usage text. Before running anything, it checks whether the shell is elevated and warns when a command needs elevated permissions.

PcHealth — the checks behind the menu

An ever expanding script for PC health and maintenance. Includes routine tasks and functions used for monitoring, and executing remote commands related to PC health and maintenance. This includes update checks, temp file deleting, monitoring of specific open ports and network health monitoring to name a few. Each command has its own power-script logic

Write-Slow — the typing effect

Every message goes through a Write-Slow function, a small helper that prints text with an optional colour and easy to read format. Pressing Enter while it types skips straight to the full message, using [Console]::KeyAvailable so the prompt never hangs waiting for input. It is deliberately slow so the person running the script doesn't have a wall of text shot at them when running the automated scripts.

Design notes

You can design batch scripts that basically run from top to bottom, executing commands one after the other, but with Powershell scripts you can create custom logic using Object Oriented Programming. Each of these functions has its own logic. With Object Oriented Programming, you can basically automate anything with error control.

Back to IT Projects