HEMM Part 1: Creating your own Powershell administration Module

🧠 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.

Leave a Reply

Your email address will not be published. Required fields are marked *