Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

System Scripts

PowerShell scripts for Windows system administration: managing environment variables, finding installed software, checking system uptime, updating software, and more.

Prerequisites

  • PowerShell 7+
  • Some scripts require administrator privileges (Update-Modules.ps1, Update-Software.ps1, Sync-TimeWithWindows.ps1)
  • Some scripts are Windows only (Get-InstalledSoftware.ps1, Get-WifiPassword.ps1, Get-UpTime.ps1, Max-Window.ps1, Sync-TimeWithWindows.ps1)
  • For repository-wide setup checks, use Initialize-ScriptPrerequisites.ps1

Scripts

Add-DirToSystemEnv.ps1

Alias: adtse

Adds a directory and all of its subdirectories to $env:Path for the current session. Optionally reloads the PowerShell profile.

# Add current directory and subdirectories to PATH
Add-DirToSystemEnv.ps1

# Add a specific directory
Add-DirToSystemEnv.ps1 -PathToAdd "C:\Work\my-daily-scripts"

# Add and reload the session profile
Add-DirToSystemEnv.ps1 -PathToAdd "C:\Work\my-daily-scripts" -RestartCurrentSession

📖 About Environment Variables


Change-PowershellFolder.ps1

Changes the default starting folder for PowerShell sessions.

Change-PowershellFolder.ps1

Count-FilePages.ps1

Alias: count-filepages

Scans a folder (recursively) for PDF and DOCX files, counts their pages, and exports a summary CSV.

Requires: pdfinfo for PDF page counting.

Count-FilePages.ps1 -Folder "C:\docs" -PdfInfoPath "C:\tools\pdfinfo.exe"

📖 xpdf / pdfinfo


Get-EnvFromFile.ps1

Reads a .env file and loads all key=value pairs as environment variables in the current session.

Get-EnvFromFile -EnvFileToReadFrom "sample.env"

Get-EnvVars.ps1

Reads a .env file and sets each KEY=VALUE pair as an environment variable in the current session.

Get-EnvVars -EnvFile "C:\Work\.env"

Format of the .env file:

MY_API_KEY=abc123
DATABASE_URL=Server=localhost;Database=mydb

Get-FolderFilesCount.ps1

Alias: gfc

Counts the number of files and directories in a given folder (recursively).

# Count in current folder
Get-FolderFilesCount.ps1

# Count in a specific folder
Get-FolderFilesCount.ps1 -Folder "C:\Work"

Get-InstalledSoftware.ps1

Lists all installed software on the machine by querying the Windows registry. Supports filtering by name.

⚠️ Windows only

# List all installed software
Get-InstalledSoftware.ps1

# Filter by name
Get-InstalledSoftware.ps1 -SoftwareName "Visual Studio"

📖 Windows Registry


Get-MyFolderItem.ps1

Alias: gfi

A wrapper around Get-ChildItem that sorts results by LastWriteTime. Accepts all Get-ChildItem parameters including -File, -Directory, -Filter, -Include, -Exclude, and -Recurse.

# List all items sorted by last write time
Get-MyFolderItem -Path C:\scripts

# List only files modified recently, excluding test scripts
Get-MyFolderItem -Path C:\scripts -Recurse -File -Exclude *.test.ps1 | Select-Object -Last 5

# Using the alias
gfi -Path C:\scripts -Directory -Recurse | Select-Object -Last 3

📖 Get-ChildItem documentation


Get-ScriptCatalog.ps1

Builds a catalog of scripts in this repository (name, path, category, summary, runnable state).

# Return objects
Get-ScriptCatalog.ps1

# Return JSON
Get-ScriptCatalog.ps1 -AsJson

Initialize-ScriptPrerequisites.ps1

Checks required/recommended prerequisites across this repository and can optionally install missing modules/Azure CLI.

# Check only
Initialize-ScriptPrerequisites.ps1

# Install missing modules and Azure CLI when missing
Initialize-ScriptPrerequisites.ps1 -InstallMissingModules -InstallAzureCli

Invoke-ScriptLauncher.ps1

Interactive launcher to search scripts, preview documentation, and execute selected entries.

# Interactive search and execution
Invoke-ScriptLauncher.ps1

# Start with a filter
Invoke-ScriptLauncher.ps1 -Search "azure"

# Preview docs only
Invoke-ScriptLauncher.ps1 -PreviewOnly

Get-UpTime.ps1

Alias: uptime

Returns the system uptime as a TimeSpan object by querying the last boot time from WMI.

⚠️ Windows only — uses Win32_OperatingSystem WMI class.

Get-UpTime.ps1

📖 Win32_OperatingSystem WMI class


Get-WifiPassword.ps1

Displays all stored Wi-Fi passwords on the machine using netsh wlan export profile.

⚠️ Windows only — requires netsh (Windows built-in).

# Import the function
. .\Get-WifiPassword.ps1

# Show all Wi-Fi passwords
Get-WifiPassword

Based on the work from HCRitter/Get-WIFIPassword.


Max-Window.ps1

Alias: mw

Finds a running process by name and maximizes its window using the Windows user32.dll API.

⚠️ Windows only — uses P/Invoke to call ShowWindowAsync and SetForegroundWindow.

Max-Window.ps1 -ProcessName "notepad"
Max-Window.ps1 -ProcessName "devenv"

Search-StartMenu.ps1

Searches both the user and all-users Start Menu folders for shortcuts matching a pattern.

⚠️ Windows only

# Search and run the first match
Search-StartMenu "Character Map" | Invoke-Item

# Search interactively
Search-StartMenu "PowerShell" | Select-FilteredObject | Invoke-Item

Sync-TimeWithWindows.ps1

Synchronizes the system clock with time.windows.com using the Windows Time service (w32tm).

⚠️ Windows only — requires Administrator privileges

Sync-TimeWithWindows.ps1

📖 Windows Time service


Update-Modules.ps1

Updates all installed PowerShell modules to their latest version and removes older installed versions.

Requires Administrator privileges

# Update to latest stable release
Update-Modules.ps1

# Update to latest prerelease version
Update-Modules.ps1 -AllowPrerelease

Based on a script from powershellisfun.com.

📖 Update-Module documentation


Update-Software.ps1

Updates all installed software using both Winget and Chocolatey package managers in a single command.

Requires Administrator privileges

# Update all software silently
Update-Software.ps1

# Update with confirmation prompts
Update-Software.ps1 -Confirm

# Check if Chocolatey is installed before trying to use it
Update-Software.ps1 -CheckIfChocolateyIsInstalled

📖 winget documentation 📖 Chocolatey documentation


Tests

Tests are in the tests/ folder and use Pester.

Invoke-Pester -Path ./tests/System.Tests.ps1 -Output Detailed

Tests include syntax validation, parameter checks, and functional tests for:

  • Add-DirToSystemEnv.ps1 — validates directory is added to PATH
  • Get-EnvVars.ps1 — validates env file parsing and variable setting
  • Get-FolderFilesCount.ps1 — validates folder scanning
  • Get-MyFolderItem.ps1 — validates function definition and file listing

Additional Resources