![Pester tests coverage](https://img.shields.io/badge/Pester_coverage-3052_%E2%80%B1-orange red)
This repo contains a collection of generally useful scripts (mostly Windows PowerShell).
See PS5 for legacy scripts, syscfg for single-use system config scripts.
- Convert-ClipboardTsvToHtml.ps1: Parses TSV clipboard data into HTML table data which is copied back to the clipboard.
- Import-ClipboardTsv.ps1: Parses TSV clipboard data into objects.
- Find-Comics.ps1: Finds comics.
- Get-Comics.ps1: Returns a cached list of comics from the Shortboxed API.
- Open-Comic.ps1: Opens a comic's PreviewsWorld page.
- Get-CommandParameters.ps1: Returns the parameters of the specified cmdlet.
- Get-CommandPath.ps1: Locates a command.
- 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.
- Get-ConfigConnectionStringBuilders.ps1: Return named connection string builders for connection strings in a config file.
- Get-NuGetConfigs.ps1: Returns the available NuGet configuration files, in order of preference.
- Use-NetMailConfig.ps1: Use .NET configuration to set defaults for Send-MailMessage.
- Disable-AnsiColor.ps1: Disables ANSI terminal colors.
- Enable-AnsiColor.ps1: Enables ANSI terminal colors.
- Get-ConsoleHistory.ps1: Returns the DOSKey-style console command history (up arrow or F8).
- Set-ConsoleColorTheme.ps1: Overrides ConsoleClass window color palette entries with a preset color theme.
- Export-SecretVault.ps1: Exports secret vault content.
- Get-CachedCredential.ps1: Return a credential from secure storage, or prompt the user for it if not found.
- Import-SecretVault.ps1: Imports secrets into secret vaults.
- Remove-CachedCredential.ps1: Removes a credential from secure storage.
- Limit-Digits.ps1: Rounds off a number to the requested number of digits.
- Measure-Values.ps1: Provides analysis of supplied values.
- ConvertFrom-Base64.ps1: Converts base64-encoded text to bytes or text.
- ConvertFrom-Hex.ps1: Convert a string of hexadecimal digits into a byte array.
- ConvertTo-Base64.ps1: Converts bytes or text to base64-encoded text.
- ConvertTo-PowerShell.ps1: Serializes complex content into PowerShell literals.
- Format-EscapedUrl.ps1: Escape URLs more aggressively.
- New-Jwt.ps1: Generates a JSON Web Token (JWT)
- Split-Uri.ps1: Splits a URI into component parts.
- Test-FileTypeMagicNumber.ps1: Tests for a given common file type by magic number.
- Test-Jwt.ps1: Determines whether a string is a valid JWT.
- Test-MagicNumber.ps1: Tests a file for a "magic number" (identifying sequence of bytes) at a given location.
- Test-Uri.ps1: Determines whether a string is a valid URI.
- 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.
- π Export-DatabaseScripts.ps1: Exports MS SQL database objects from the given server and database as files, into a consistent folder structure.
- Export-TableMerge.ps1: Exports table data as a T-SQL MERGE statement.
- Find-DatabaseValue.ps1: Searches an entire database for a field value.
- Find-DbColumn.ps1: Searches for database columns.
- Find-Indexes.ps1: Returns indexes using a column with the given name.
- Find-SqlDeprecatedLargeValueTypes.ps1: Reports text, ntext, and image datatypes found in a given database.
- Initialize-DatabaseNotebook.ps1: Populates a new notebook with details about a database.
- Measure-DbColumn.ps1: Provides statistics about SQL Server column data.
- Measure-DbColumnValues.ps1: Provides sorted counts of SQL Server column values.
- Measure-DbTable.ps1: Provides frequency details about SQL Server table data.
- New-DbProviderObject.ps1: Create a common database object.
- Repair-DatabaseConstraintNames.ps1: Finds database constraints with system-generated names and gives them deterministic names.
- Repair-DatabaseUntrustedConstraints.ps1: Finds database constraints that have been incompletely re-enabled.
- Send-SqlReport.ps1: Execute a SQL statement and email the results.
- Test-ConnectionString.ps1: Test a given connection string and provide details about the connection.
- Use-SqlcmdParams.ps1: Use the calling script parameters to set Invoke-Sqlcmd defaults.
- Add-TimeSpan.ps1: Adds a timespan to DateTime values.
- ConvertFrom-Duration.ps1: Parses a Timespan from a ISO8601 duration string.
- ConvertFrom-EpochTime.ps1: Converts an integer Unix (POSIX) time (seconds since Jan 1, 1970) into a DateTime value.
- ConvertFrom-IsoWeekDate.ps1: Returns a DateTime object from an ISO week date string.
- ConvertTo-EpochTime.ps1: Converts a DateTime value into an integer Unix (POSIX) time, seconds since Jan 1, 1970.
- ConvertTo-LogParserTimestamp.ps1: Formats a datetime as a LogParser literal.
- Format-Date.ps1: Returns a date/time as a named format.
- Get-FrenchRepublicanDate.ps1: Returns a date and time converted to the French Republican Calendar.
- Show-Time.ps1: Displays a formatted date using powerline font characters.
- Test-DateTime.ps1: Tests whether the given string can be parsed as a date.
- Test-USFederalHoliday.ps1: Returns true if the given date is a U.S. federal holiday.
- Compare-Keys.ps1: Returns the differences between two dictionaries.
- ConvertTo-OrderedDictionary.ps1: Converts an object to an ordered dictionary of properties and values.
- Join-Keys.ps1: Combines dictionaries together into a single dictionary.
- Remove-NullValues.ps1: Removes dictionary entries with null vaules.
- Split-Keys.ps1: Clones a dictionary keeping only the specified keys.
- Find-DotNetGlobalTools.ps1: Returns a list of global dotnet tools.
- Get-AssemblyFramework.ps1: Gets the framework version an assembly was compiled for.
- 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.
- Compress-EnvironmentVariables.ps1: Replaces each of the longest matching parts of a string with an embedded environment variable with that value.
- Expand-EnvironmentVariables.ps1: Replaces the name of each environment variable embedded in the specified string with the string equivalent of the value of the variable, then returns the resulting string.
- Backup-File.ps1: Create a backup as a sibling to a file, with date and time values in the name.
- Find-DuplicateFiles.ps1: Removes duplicates from a list of files.
- Find-NewestFile.ps1: Finds the most recent file.
- 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.
- Test-NewerFile.ps1: Returns true if the difference file is newer than the reference file.
- Update-Files.ps1: Copies specified source files that exist in the destination directory.
- π Add-GitHubMetadata.ps1: Adds GitHub Linguist overrides to a repo's .gitattributes.
- Copy-GitHubLabels.ps1: Copies configured issue labels from one repo to another.
- Get-GitFileMetadata.ps1: Returns the creation and last modification metadata for a file in a git repo.
- Get-GitFirstCommit.ps1: Gets the SHA-1 hash of the first commit of the current repo.
- Get-RepoName.ps1: Gets the name of the repo.
- Rename-GitHubLocalBranch.ps1: Rename a git repository branch.
- Trace-GitRepoTest.ps1: Uses git bisect to search for the point in the repo history that the test script starts returning true.
- ConvertTo-BasicAuthentication.ps1: Produces a basic authentication header string from a credential.
- ConvertTo-MultipartFormData.ps1: Creates multipart/form-data to send as a request body.
- Get-ContentSecurityPolicy.ps1: Returns the content security policy at from the given URL.
- Get-SslDetails.ps1: Enumerates the SSL protocols that the client is able to successfully use to connect to a server.
- Save-WebRequest.ps1: Downloads a given URL to a file, automatically determining the filename.
- Show-HttpStatus.ps1: Displays the HTTP status code info.
- π Export-Json.ps1: Exports a portion of a JSON document, recursively importing references.
- π Export-OpenApiSchema.ps1: Extracts a JSON schema from an OpenAPI definition.
- π Get-OpenApiInfo.ps1: Returns metadata from an OpenAPI definition.
- Merge-Json.ps1: Create a new JSON string by recursively combining the properties of JSON strings.
- π Resolve-JsonPointer.ps1: Returns matching JSON Pointer paths, given a JSON Pointer path with wildcards.
- π Select-Json.ps1: Returns a value from a JSON string or file.
- π Set-Json.ps1: Sets a property in a JSON string or file.
- π Show-OpenApiInfo.ps1: Displays metadata from an OpenAPI definition.
- Add-NotebookCell.ps1: When run within a Polyglot Notebook, appends a cell to it.
- Find-ProjectPackages.ps1: Find modules used in projects.
- Get-LibraryVulnerabilityInfo.ps1: Get the list of module/package/library vulnerabilities from the RetireJS or SafeNuGet projects.
- Add-ParameterDefault.ps1: Appends or creates a value to use for the specified cmdlet parameter to use when one is not specified.
- Remove-ParameterDefault.ps1: Removes a value that would have been used for a parameter if none was specified, if one existed.
- Set-ParameterDefault.ps1: Assigns a value to use for the specified cmdlet parameter to use when one is not specified.
- Add-Counter.ps1: Adds an incrementing integer property to each pipeline object.
- Add-DynamicParam.ps1: Adds a dynamic parameter to a script, within a DynamicParam block.
- Add-ScopeLevel.ps1: Convert a scope level to account for another call stack level.
- ForEach-Progress.ps1: Performs an operation against each item in a collection of input objects, with a progress bar.
- Format-ByteUnits.ps1: Converts bytes to largest possible units, to improve readability.
- Format-Permutations.ps1: Builds format strings using every combination of elements from multiple arrays.
- Get-EnumValues.ps1: Returns the possible values of the specified enumeration.
- Get-TypeAccelerators.ps1: Returns the list of PowerShell type accelerators.
- Import-Variables.ps1: Creates local variables from a data row or dictionary (hashtable).
- Invoke-WindowsPowerShell.ps1: Runs commands in Windows PowerShell (typically from PowerShell Core).
- Merge-PSObject.ps1: Create a new PSObject by recursively combining the properties of PSObjects.
- Read-Choice.ps1: Returns choice selected from a list of options.
- Stop-ThrowError.ps1: Throws a better error than "throw".
- Test-Administrator.ps1: Checks whether the current session has administrator privileges.
- Test-Interactive.ps1: Determines whether both the user and process are interactive.
- Test-Range.ps1: Returns true from an initial condition until a terminating condition; a latching test.
- Test-Variable.ps1: Indicates whether a variable has been defined.
- Use-ProgressView.ps1: Sets the progress bar display view.
- Use-ReasonableDefaults.ps1: Sets certain cmdlet parameter defaults to rational, useful values.
- Write-Info.ps1: Writes to the information stream, with color support and more.
- Uninstall-OldModules.ps1: Uninstalls old module versions.
- Update-Modules.ps1: Cleans up old modules.
- Add-NoteProperty.ps1: Adds a NoteProperty to a PSObject, calculating the value with the object in context.
- Compare-Properties.ps1: Compares the properties of two objects.
- Test-NoteProperty.ps1: Looks for any matching NoteProperties on an object.
- 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.
- ConvertTo-ICalendar.ps1: Converts supported objects (Scheduled Tasks) to the RFC 5545 iCalendar format.
- Copy-SchTasks.ps1: Copy scheduled jobs from another computer to this one, using a GUI list to choose jobs.
- Restore-SchTasks.ps1: Imports from a single XML file into the local Scheduled Tasks.
- 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.
- Repair-ScriptStyle.ps1: Accepts justifications for script analysis rule violations, fixing the rest using Invoke-ScriptAnalysis.
- Add-CapturesToMatches.ps1: Adds named capture group values as note properties to Select-String MatchInfo objects.
- Find-Lines.ps1: Searches a specific subset of files for lines matching a pattern.
- Select-CapturesFromMatches.ps1: Selects named capture group values as note properties from Select-String MatchInfo objects.
- Set-RegexReplace.ps1: Updates text found with Select-String, using a regular expression replacement template.
- Send-SeqEvent.ps1: Send an event to a Seq server.
- Send-SeqScriptEvent.ps1: Sends an event (often an error) from a script to a Seq server, including script info.
- Use-SeqServer.ps1: Set the default Server and ApiKey for Send-SeqEvent.ps1
- 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.
- ConvertTo-SafeEntities.ps1: Encode text as XML/HTML, escaping all characters outside 7-bit ASCII.
- Get-CharacterDetails.ps1: Returns filterable categorical information about characters in the Unicode Basic Multilingual Plane.
- Get-Unicode.ps1: Returns the (UTF-16) .NET string for a given Unicode codepoint, which may be a surrogate pair.
- Get-UnicodeByName.ps1: Returns characters based on Unicode code point name, GitHub short code, or HTML entity.
- Get-UnicodeData.ps1: Returns the current (cached) Unicode character data.
- Get-UnicodeName.ps1: Returns the name of a Unicode code point.
- Import-CharConstants.ps1: Imports characters by name as constants into the current scope.
- π Add-VsCodeDatabaseConnection.ps1: Adds a VS Code MSSQL database connection to the repo.
- π Get-VSCodeSetting.ps1: Sets a VSCode setting.
- Get-VSCodeSettingsFile.ps1: Gets the path of the VSCode settings.config file.
- Import-VsCodeDatabaseConnections.ps1: Adds config XDT connection strings to VSCode settings.
- Push-WorkspaceLocation.ps1: Pushes the current VS Code editor workspace location to the location stack.
- π Set-VSCodeSetting.ps1: Sets a VSCode setting.
- Compare-Xml.ps1: Compares two XML documents and returns the differences.
- Convert-Xml.ps1: Transform XML using an XSLT template.
- ConvertFrom-EscapedXml.ps1: Parse escaped XML into XML and serialize it.
- ConvertFrom-XmlElement.ps1: Converts named nodes of an element to properties of a PSObject, recursively.
- ConvertTo-XmlElements.ps1: Serializes complex content into XML elements.
- Format-Xml.ps1: Pretty-print XML.
- Get-XmlNamespaces.ps1: Gets the namespaces from a document as a dictionary.
- Merge-XmlSelections.ps1: Builds an object using the named XPath selections as properties.
- New-NamespaceManager.ps1: Creates an object to lookup XML namespace prefixes.
- Resolve-XmlSchemaLocation.ps1: Gets the namespaces and their URIs and URLs from a document.
- Resolve-XPath.ps1: Returns the XPath of the location of an XML node.
- Show-DataRef.ps1: Display an HTML view of an XML schema or WSDL using Saxon.
- Test-Xml.ps1: Try parsing text as XML, and validating it if a schema is provided.
- Backup-Workstation.ps1: Adds various configuration files and exported settings to a ZIP file.
- Connect-SshKey.ps1: Uses OpenSSH to generate a key and connect it to an ssh server.
- ConvertTo-RomanNumeral.ps1: Convert a number to a Roman numeral.
- Copy-Html.ps1: Copies objects as an HTML table.
- π Export-MermaidER.ps1: Generates a Mermaid entity relation diagram for database tables.
- Export-Readme.ps1: Generate README.md file for the scripts repo.
- Format-HtmlDataTable.ps1: Right-aligns numeric data in an HTML table for emailing, and optionally zebra-stripes &c.
- 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-Dns.ps1: Looks up DNS info, given a hostname or address.
- Get-GitHubRepoChildItem.ps1: Gets the items and child items in one or more specified locations.
- Get-IisLog.ps1: Easily query IIS logs.
- Get-PocketArticles.ps1: Retrieves a list of saved articles from a Pocket account.
- Get-RandomBytes.ps1: Returns random bytes.
- Get-Todos.ps1: Returns the TODOs for the current git repo, which can help document technical debt.
- 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.
- Remove-PocketArticle.ps1: Removes an article from a Pocket account.
- Repair-AppxPackages.ps1: Re-registers all installed Appx packages.
- Restore-Workstation.ps1: Restores various configuration files and exported settings from a ZIP file.
- Save-PodcastEpisodes.ps1: Downloads enclosures from a podcast feed.
- Send-MailMessageFile.ps1: Sends emails from a drop folder using .NET config defaults.
- Test-HttpSecurity.ps1: Scan sites using Mozilla's Observatory.
- π Write-CallInfo.ps1: Prints caller name and parameters to the host for debugging purposes.
- Write-VisibleString.ps1: Displays a string, showing nonprintable characters.
- 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)