-
Notifications
You must be signed in to change notification settings - Fork 0
Scripts Windows Utilities
Scripts in Scripts/Windows/Utilities/.
What it does: Lists all running processes that have a visible main window, showing their process name and window title.
Parameters: None. No admin rights required.
Usage:
.\Scripts\Windows\Utilities\Get-OpenWindows.ps1Example output:
--- Active Window Titles ---
ProcessName MainWindowTitle
--------------------------------------------------------
Code Sync-Directories.ps1 - PotentPowershell - Visual Studio Code
WindowsTerminal PowerShell
msedge GitHub - Microsoft Edge
Use case: When writing automation scripts that target windows by title (e.g., Set-WindowPosition, SendKeys, AutoHotkey integration), use this script to find the exact MainWindowTitle string for the window you want to target.
What it does: Configures PowerShell to auto-elevate every new window to admin.
Steps performed:
- Auto-elevates if not already admin.
- Sets execution policy to
Unrestrictedfor the current user. - Creates the PowerShell profile file (
Microsoft.PowerShell_profile.ps1) if it does not exist. - Appends an auto-elevation snippet to the profile that re-launches any non-admin PowerShell window as admin.
- Dot-sources the profile to apply changes immediately.
Parameters: None.
Requirements: Auto-elevates if not admin.
Usage:
.\Scripts\Windows\Utilities\Set-AdminAutoElevate.ps1Security note: This script sets the execution policy to Unrestricted for the current user, which allows any local or remote script to run without a prompt. RemoteSigned is a safer alternative — it still requires local scripts to be unblocked but blocks remote scripts without a trusted signature. If you want RemoteSigned behavior, edit the script before running:
# Change this line in the script:
Set-ExecutionPolicy Unrestricted -Scope CurrentUser -Force
# To:
Set-ExecutionPolicy RemoteSigned -Scope CurrentUser -ForceProfile location: $env:USERPROFILE\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1
This is the Windows PowerShell 5.1 profile path. PowerShell 7 uses a different profile path ($env:USERPROFILE\Documents\PowerShell\Microsoft.PowerShell_profile.ps1). If you use both, run the snippet appended to each profile separately.
What it does: Completely removes Microsoft Silverlight from the system.
Microsoft Silverlight reached end-of-life in October 2021. No modern browser supports it. Removing it reduces attack surface.
Steps performed:
- Locates
Silverlight.Configuration.exeinC:\Program Files (x86)\Microsoft Silverlight\. - Runs the silent uninstaller (
/uninstall /force /silent). - Removes registry entries under
HKLM:\Software\Microsoft\Silverlightand the Silverlight uninstall key. - Deletes
C:\Program Files (x86)\Microsoft Silverlightdirectory. - Deletes the Silverlight browser plugin from
%AppData%\Microsoft\Plugins.
Parameters: None.
Requirements: Administrator access recommended (registry and Program Files). Safe no-op if Silverlight is not installed.
Usage:
.\Scripts\Windows\Utilities\Remove-Silverlight.ps1What it does: Reports the full Bounds and WorkingArea for each connected monitor, using System.Windows.Forms.Screen.
Parameters: None. No admin rights required.
Usage:
.\Scripts\Windows\Utilities\Get-ScreenGeometry.ps1Example output:
--- Your Screen Geometry ---
Screen #1
Primary : True
Bounds : X=0, Y=0, W=2560, H=1440
Working Area : X=0, Y=0, W=2560, H=1400
Device Name : \\.\DISPLAY1
Screen #2
Primary : False
Bounds : X=2560, Y=0, W=1920, H=1080
Working Area : X=2560, Y=0, W=1920, H=1080
Device Name : \\.\DISPLAY2
Bounds vs WorkingArea:
- Bounds — the full physical screen rectangle, including any space the taskbar occupies.
- WorkingArea — the usable area excluding the taskbar. Use this for window placement so windows don't appear behind the taskbar.
Use case: Window management scripts that need to position windows relative to monitor boundaries. The Bounds.X of a secondary monitor is its offset from the primary (usually primary.Width).
What it does: Copies all files from a source directory to a destination using Robocopy with 64 parallel threads.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
-Source |
string |
Yes | The source directory to copy from |
-Destination |
string |
Yes | The destination directory to copy to |
Robocopy flags used:
| Flag | Meaning |
|---|---|
/E |
Copy subdirectories, including empty ones |
/XC |
Exclude changed files (skip files that already exist with the same timestamp) |
/NP |
No per-file progress percentage (reduces output noise) |
/ETA |
Show estimated time of arrival for each file |
/MT:64 |
Use 64 parallel threads |
Usage:
# Sync a local directory to a backup location
.\Scripts\Windows\Utilities\Sync-Directories.ps1 -Source "D:\Data" -Destination "E:\Backup\Data"
# Sync from a network share to local
.\Scripts\Windows\Utilities\Sync-Directories.ps1 -Source "\\server\share" -Destination "C:\LocalCopy"Exit codes: Robocopy uses a bitmap exit code. This script treats codes 0–3 as success and codes ≥ 4 as a warning:
| Code | Meaning |
|---|---|
| 0 | No files copied (destination already in sync) |
| 1 | Files copied successfully |
| 2 | Extra files detected in destination (not an error) |
| 3 | Some files copied + extra files in destination |
| 4 | Mismatched files |
| 8 | Some files could not be copied (check for permission errors) |
| 16 | Fatal error |
Notes:
-
/MT:64uses 64 I/O threads. On slow storage (especially HDDs or slow network shares), high thread counts can cause seek thrashing. Reduce to/MT:8or/MT:16if you experience this. -
/XCskips files with matching timestamps — it does not compare file contents. If you need content-based deduplication, use/XCTor a different tool. - This script does not mirror (delete destination files not in source). Use
/MIRin Robocopy if you need mirror behavior, but be careful —/MIRdeletes.
What it does: Opens Microsoft Edge to the MS Edge Search Clicker page, waits a configurable number of seconds, then closes Edge.
Intended for automated daily Microsoft Rewards search point accumulation.
Parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
-WaitSeconds |
int |
120 |
Seconds to keep Edge open before closing |
Requirements: Microsoft Edge installed at C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe. If Edge is installed elsewhere, update the $edgePath variable in the script.
Usage:
# Default: 120 seconds
.\Scripts\Windows\Utilities\Start-MSRewards.ps1
# Custom wait time
.\Scripts\Windows\Utilities\Start-MSRewards.ps1 -WaitSeconds 180Notes:
- The script uses
Stop-Process -Name 'msedge'to close Edge — this closes all Edge windows, not just the one it opened. Do not run other Edge sessions you need to keep when using this script. - The search clicker URL (
https://greybax.github.io/MSEdgeSearchClicker) is a third-party tool. Verify it still functions and complies with Microsoft Rewards terms of service before use. Microsoft's ToS for Rewards programs can restrict automated point collection. - If Edge is not found at the hardcoded path, the script exits with a warning and does nothing.