
Note
Many scripts have been moved into modules to improve their usability! See ModernConveniences and the scripts-to-modules.json roadmap. Use Convert-ExternalScriptToModule.ps1 to convert your scripts!
This repo contains a collection of generally useful scripts (mostly Windows PowerShell).
See PS5 for legacy scripts, syscfg for single-use system config scripts.
- π Hide-Command.ps1: Make a command unavailable.
- π Invoke-CommandWithParams.ps1: Execute a command by using matching dictionary entries as parameters.
- π Use-Command.ps1: Checks for the existence of the given command, and adds if missing and a source is defined.
- π Use-NetMailConfig.ps1: Use .NET configuration to set defaults for Send-MailMessage.
- Set-ConsoleColorTheme.ps1: Overrides ConsoleClass window color palette entries with a preset color theme.
- π Get-CachedCredential.ps1: Return a credential from secure storage, or prompt the user for it if not found.
- π Remove-CachedCredential.ps1: Removes a credential from secure storage.
- Save-Secret.ps1: Sets a secret in a secret vault with metadata.
- Test-Windows1252.ps1: Determines whether a file contains Windows-1252 bytes that are invalid UTF-8 bytes.
- π ConvertFrom-DataRow.ps1: Converts a DataRow object to a PSObject, Hashtable, or single value.
- π Use-SqlcmdParams.ps1: Use the calling script parameters to set Invoke-Sqlcmd defaults.
- ConvertTo-LogParserTimestamp.ps1: Formats a datetime as a LogParser literal.
- Get-DotNetFrameworkVersions.ps1: Determine which .NET Frameworks are installed on the requested system.
- Get-DotNetGlobalTools.ps1: Returns a list of global dotnet tools.
- Get-DotNetVersions.ps1: Determine which .NET Core & Framework versions are installed.
- π Update-DotNetPackages.ps1: Updates NuGet packages for a .NET solution or project.
- Compress-EnvironmentVariables.ps1: Replaces each of the longest matching parts of a string with an embedded environment variable with that value.
- Join-FileName.ps1: Combines a filename with a string.
- π Measure-Caches.ps1: Returns a list of matching cache directories, and their sizes, sorted.
- New-Shortcut.ps1: Create a Windows shortcut.
- Remove-LockyFile.ps1: Removes a file that may be prone to locking.
- Test-LockedFile.ps1: Returns true if the specified file is locked.
- Find-ProjectPackages.ps1: Find modules used in projects.
- π Add-ScopeLevel.ps1: Convert a scope level to account for another call stack level.
- π Convert-ExternalScriptToModule.ps1: Convert a script from external script usage to module cmdlet usage.
- Backup-SchTasks.ps1: Exports the local list of Scheduled Tasks into a single XML file.
- π ConvertFrom-CimInstance.ps1: Convert a CimInstance object to a PSObject.
- Copy-SchTasks.ps1: Copy scheduled jobs from another computer to this one, using a GUI list to choose jobs.
- Get-SimpleSchTasks.ps1: Returns simple scheduled task info.
- Restore-SchTasks.ps1: Imports from a single XML file into the local Scheduled Tasks.
- Set-SchTaskMsa.ps1: Sets a Scheduled Task's runtime user as the given gMSA/MSA.
- π New-PesterTests.ps1: Creates a new Pester testing script from a script's examples and parameter sets.
- π New-Script.ps1: Creates a simple boilerplate script.
- Optimize-Help.ps1: Cleans up comment-based help blocks by fully unindenting and capitalizing dot keywords.
- π Rename-Script.ps1: Renames all instances of a script, and updates any usage of it.
- Find-Lines.ps1: Searches a specific subset of files for lines matching a pattern.
- Convert-ChocolateyToWinget.ps1: Change from managing various packages with Chocolatey to WinGet.
- Export-EdgeKeywords.ps1: Returns the configured search keywords from an Edge SQLite file.
- Export-InstalledPackages.ps1: Exports the list of packages installed by various tools.
- Find-InstalledPrograms.ps1: Searches installed programs.
- Get-SystemDetails.ps1: Collects some useful system hardware and operating system details via CIM.
- Import-EdgeKeywords.ps1: Adds search keywords to an Edge SQLite profile configuration.
- π Read-ChocolateySummary.ps1: Retrieves the a summary from the Chocolatey log.
- π Update-Everything.ps1: Updates everything it can on the system.
- Use-Java.ps1: Switch the Java version for the current process by modifying environment variables.
- Get-UnicodeData.ps1: Returns the current (cached) Unicode character data.
- π Set-TerminalProfile.ps1: Adds or updates a Windows Terminal command profile.
- Test-WindowsTerminal.ps1: Returns true if PowerShell is running within Windows Terminal.
- π Backup-Workstation.ps1: Adds various configuration files and exported settings to a ZIP file.
- π Export-Readme.ps1: Generate README.md file for the scripts repo.
- Get-ADServiceAccountInfo.ps1: Lists the Global Managed Service Accounts for the domain, including the computers they are bound to.
- Get-AspNetEvents.ps1: Parses ASP.NET errors from the event log on the given server.
- Get-IisLog.ps1: Easily query IIS logs.
- Get-PathUsage.ps1: Returns the list of directories in the path, and the commands found in each.
- Measure-Indents.ps1: Measures the indentation characters used in a text file.
- Measure-StandardDeviation.ps1: Calculate the standard deviation of numeric values.
- Measure-TextFile.ps1: Counts each type of indent and line ending.
- π New-RandomVehicle.ps1: Generates random vehicle details with a valid VIN.
- π Optimize-Path.ps1: Sorts, prunes, and normalizes both user and system Path entries.
- Repair-AppxPackages.ps1: Re-registers all installed Appx packages.
- π Restore-Workstation.ps1: Restores various configuration files and exported settings from a ZIP file.
- Send-MailMessageFile.ps1: Sends emails from a drop folder using .NET config defaults.
- NCrontab Schedule Test: Returns a sampling of the next several date & times scheduled by an NCrontab string.
- Parse Unicode data: Experiment with CSV type provider to read Unicode data.
- US Federal Holiday Detection: Here's how to determine whether a date is a US federal holiday using F#.
- OutlookExpireTag.vba: Too many emails remain beyond their period of relevance: daily personnel schedule changes, found item notices, office food notices, server reboot notices, weather/traffic warnings, &c. This Outlook script will allow specifying an expiration date as a hashtag in the subject of outgoing emails, since Outlook does such a good job of hiding the UI for that field. -BL
- OutlookPasteFormattedIndented.vba: Outlook will strip single-space indents when displaying emails. If you've got, for example, syntax highlighted source code that employs any indentation of only one space, you'll want to add two spaces to the each line (adding one will not appear for text that isn't indented). This Outlook script will paste formatted text, and indent it. Requires Tools -> References -> Microsoft Word 14.0 Object Library (later versions may also work)
- OutlookPasteTsvTable.vba: This Outlook VBA Sub can be connected to a toolbar button for pasting TSV data as an attractive, formatted table. -BL Requires Tools -> References -> Microsoft Word 14.0 Object Library (later versions may also work)