π§ TL;DR
If your script collection looks like a junk drawer full of tangled cables and half-written functions, itβs time to fix that. This guide sets up a standard PowerShell administration Module structure to clean up your mess and keep future scripts organised: HEMM (Hay-Ellis Master Module).
Overview
Letβs be honest β most of us have a spaghetti mess of PowerShell scripts collected over the years. No structure, no naming standards, no clue what half of it does anymore. HEMM fixes that by introducing a clean module system with a predictable layout, reusable functions, and a clear naming convention.
HEMM (Hay-Ellis Master Module).
ποΈFolder Layout
/HEMM # Hay-Ellis Master Module
βββ Common # Shared files (e.g. verb lists, configs)
βββ Functions # Organised functions by type
β βββ ActiveDirectory # AD-specific scripts
β βββ Files # File and share tools
β βββ Misc # Random utilities
β βββ Network # Network/IP-related tools
βββ InputFiles # Temp: input files go here
βββ OutputFiles # Temp: output goes here
# Optional bits
βββ Archive # Old, broken, or replaced scripts
βββ Software # Stuff your tools need (installers, EXEs, etc.)
Files:
README.md # Say what this does
HEMM.psm1 # Loads your module functions
HEMM.psd1 # Manifest file
Start.ps1 # Template launcher for testing the module
π§Ό Why This Layout Works
- Software folder = one place for all your
.exe
,.msi
, or support tools - Logical grouping = no more duplicate scripts buried in weird folders
- Input/output folders = easy to clean up without losing anything critical
You can clone this from my git repo.
π§± Function Naming
Stick to the PowerShell standard: Verb-Noun
.
βοΈ Good:
Get-UserInfo
Set-LogPath
Invoke-Cleanup
β Bad:
runstuff
doThings
bob.ps1
If in doubt, thereβs a list of approved verbs in .\common\approved_verbs.txt
.
π¦ Writing the Module File (.psm1
)
This is how all your function files get loaded automatically:
# HEMM.psm1
# Dot-source all .ps1 files in the Functions folder and subfolders
Get-ChildItem -Path ".\Functions" -Recurse -Filter *.ps1 | ForEach-Object {
. $_.FullName
}
π Creating the Manifest (.psd1
)
Use this one-liner to generate it:
New-ModuleManifest -Path .\hemm.psd1 `
-RootModule 'hemm.psm1' `
-ModuleVersion '1.0.0' `
-Author 'Ashley Hay-Ellis' `
-Description 'A collection of sysadmin tools for AD, fileshares and network management'
You can tweak this file later if you want to define functions to export explicitly.
π§ͺ Testing the Module
Load the module from any path like this:
Import-Module 'c:\hemm\hemm.psd1' -Force
Use -Force
to reload after changes without restarting PowerShell
β Final Thoughts
This is your first step to turning chaos into order. Once your functions are structured and names make sense, youβll spend less time hunting and more time doing. Next up: standardising reusable function templates for consistency. See you in Part 2.