PowerShell scripts for Windows system administration: managing environment variables, finding installed software, checking system uptime, updating software, and more.
- 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
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" -RestartCurrentSessionChanges the default starting folder for PowerShell sessions.
Change-PowershellFolder.ps1Alias: 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"Reads a .env file and loads all key=value pairs as environment variables in the current session.
Get-EnvFromFile -EnvFileToReadFrom "sample.env"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=mydbAlias: 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"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"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 3Builds a catalog of scripts in this repository (name, path, category, summary, runnable state).
# Return objects
Get-ScriptCatalog.ps1
# Return JSON
Get-ScriptCatalog.ps1 -AsJsonChecks 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 -InstallAzureCliInteractive 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 -PreviewOnlyAlias: uptime
Returns the system uptime as a TimeSpan object by querying the last boot time from WMI.
⚠️ Windows only — usesWin32_OperatingSystemWMI class.
Get-UpTime.ps1📖 Win32_OperatingSystem WMI class
Displays all stored Wi-Fi passwords on the machine using netsh wlan export profile.
⚠️ Windows only — requiresnetsh(Windows built-in).
# Import the function
. .\Get-WifiPassword.ps1
# Show all Wi-Fi passwords
Get-WifiPasswordBased on the work from HCRitter/Get-WIFIPassword.
Alias: mw
Finds a running process by name and maximizes its window using the Windows user32.dll API.
⚠️ Windows only — uses P/Invoke to callShowWindowAsyncandSetForegroundWindow.
Max-Window.ps1 -ProcessName "notepad"
Max-Window.ps1 -ProcessName "devenv"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-ItemSynchronizes the system clock with time.windows.com using the Windows Time service (w32tm).
⚠️ Windows only — requires Administrator privileges
Sync-TimeWithWindows.ps1Updates 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 -AllowPrereleaseBased on a script from powershellisfun.com.
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 are in the tests/ folder and use Pester.
Invoke-Pester -Path ./tests/System.Tests.ps1 -Output DetailedTests include syntax validation, parameter checks, and functional tests for:
Add-DirToSystemEnv.ps1— validates directory is added to PATHGet-EnvVars.ps1— validates env file parsing and variable settingGet-FolderFilesCount.ps1— validates folder scanningGet-MyFolderItem.ps1— validates function definition and file listing