CablersPowershellCore is a PowerShell module designed to provide a collection of utilities for managing and automating tasks across devices. It includes functions for managing audio, disk space, installed software, and more.
- CablersPowershellCore
- Prerequisites
- Execution Policy & Code Signing
- Installation
- Functions Overview
- Compare-Files
- Compress-7z
- Convert-PrefixToSubnetMask
- Convert-StringToURI
- Get-AudioVolume
- Get-DiskSpace
- Get-InstalledSoftware
- Get-InternalIP
- Get-IPAddressLocation
- Get-LastBootTime
- Get-LongestCommonPrefix
- Get-PublicIP
- Get-Uptime
- New-Credential
- New-Password
- New-Passphrase
- Remove-EmptyFolders
- Set-AudioVolume
- Set-Owner
- Split-String
- Test-EmptyFolder
- Test-IsAdmin
- Uninstall-Software
- Write-Log
- PowerShell Version: This module requires PowerShell 5.1 or later.
- Required Modules:
-
PwnedPassCheck(Install via PowerShell Gallery):Install-Module -Name PwnedPassCheck -Scope CurrentUser
-
- PowerShell Gallery installation: When installing from the PowerShell Gallery, the module is automatically trusted through the gallery's verification process.
- Manual installation: If you download the module manually, run
Get-ChildItem -Recurse *.ps1 | Unblock-Filein the module directory to mark files as safe. - Temporarily relax policy: Use
Set-ExecutionPolicy -Scope Process -ExecutionPolicy RemoteSignedin an elevated session when testing on freshly provisioned hosts, then close the session to restore the previous policy.
This module sets RequireLicenseAcceptance = $true in the manifest. Installation via PowerShellGet prompts users to review and accept the license (see License).
The module is published to the PowerShell Gallery. Install it with:
-
All Users (requires admin, allows use by System)
Install-Module -Name CablersPowershellCore -Scope AllUsers -AllowClobber # Requires admin
-
Current User
Install-Module -Name CablersPowershellCore -Scope CurrentUser -AllowClobber
After installation, import the module:
Import-Module -Name CablersPowershellCoreNote
AllowClobber is required due to the inclusion of a few commands that already exist. This is currently only Get-Uptime which behaves exactly the same as the one built into PowerShell Core, and Get-DiskSpace which has an additional output format.
Description: Compares two files and determines if they are identical.
Parameters:
| Name | Type | Mandatory | Position | Description | Default Value |
|---|---|---|---|---|---|
| SourceFile | String | Yes | 0 | The path to the first file | |
| ComparisonFile | String | Yes | 1 | The path to the second file |
Outputs: Object with the following structure:
| Property | Type | Description |
|---|---|---|
| FilesMatch | Boolean | True if files are identical, False otherwise |
| SourceFile | String | Path to the source file |
| ComparisonFile | String | Path to the comparison file |
Description: Compresses files or folders into a .7z archive.
Parameters:
| Name | Type | Mandatory | Position | Description | Default Value |
|---|---|---|---|---|---|
| SourcePath | String | Yes | 0 | Path to the file or folder to compress | |
| DestinationPath | String | Yes | 1 | Path to save the compressed file | |
| DeleteOriginal | Switch | No | Named | Deletes the original file/folder after compression | False |
Outputs: None.
Description: Retrieves the current audio volume level.
Parameters: None.
Outputs: Integer (Volume level as a percentage).
Description: Sets the audio volume or mutes/unmutes the audio.
Parameters:
| Name | Type | Mandatory | Position | Description | Default Value |
|---|---|---|---|---|---|
| Volume | Integer | Yes | 0 | Volume level (0-100) | |
| Mute | Switch | No | Named | Mutes the audio | False |
Outputs: None.
Description: Retrieves disk space information for specified drives.
Parameters:
| Name | Type | Mandatory | Position | Description | Default Value |
|---|---|---|---|---|---|
| DriveLetter | String[ ] | No | 0 | Drive letters to query | All drives |
| Simple | Switch | No | Named | Returns a simplified output | False |
Outputs: Custom object with the following structure:
| Property | Type | Description |
|---|---|---|
| Drive | String | Drive letter with colon (e.g., "C:") |
| Label | String | Volume label |
| SizeGB | Decimal | Total size in GB |
| FreeGB | Decimal | Free space in GB |
| UsedGB | Decimal | Used space in GB |
| PercentUsed | Decimal | Percentage of used space |
| PercentFree | Decimal | Percentage of free space |
Description: Retrieves a list of installed software on the system.
Parameters:
| Name | Type | Mandatory | Position | Description | Default Value |
|---|---|---|---|---|---|
| SoftwareName | String | No | 0 | Filters results by software name (using regex) |
Outputs: Custom object with the following structure:
| Property | Type | Description |
|---|---|---|
| Name | String | Name of the installed software |
| Version | String | Version number |
| Publisher | String | Software publisher |
| InstallDate | DateTime | Date software was installed |
| UninstallString | String | Command to uninstall the software |
| QuietUninstallString | String | Command for silent uninstallation |
| GUID | String | Unique identifier for the software |
Description: Creates a new PSCredential object.
Parameters:
| Name | Type | Mandatory | Position | Description | Default Value |
|---|---|---|---|---|---|
| Username | String | Yes | 0 | The username for the credential | |
| Password | String | Yes | 1 | The password for the credential |
Outputs: PSCredential object.
Description: Checks if a folder is empty. If no path is specified, checks the current directory. Accepts pipeline input.
Aliases: isempty
Parameters:
| Name | Type | Mandatory | Pipeline Input | Position | Description | Default Value |
|---|---|---|---|---|---|---|
| Path | String | No | Yes | 0 | Path to the folder | Current directory |
Outputs: Boolean ($true if the folder is empty, $false otherwise).
Examples:
# Test current directory
Test-EmptyFolder
# Test specific folder
Test-EmptyFolder -Path "C:\Temp"
# Pipeline input (single or multiple)
"C:\Temp", "C:\Logs" | Test-EmptyFolder
# Works with Get-ChildItem
Get-ChildItem -Directory | Test-EmptyFolder
# Using alias
isempty -Path "C:\Temp"Description: Uninstalls specified software from the system.
Parameters:
| Name | Type | Mandatory | Position | Description | Default Value |
|---|---|---|---|---|---|
| SoftwareName | String | Yes | 0 | Name of the software to uninstall |
Outputs: None.
Description: Writes log messages with timestamps to console and optionally to a file. Supports different log levels (DEBUG, INFO, WARNING, ERROR), custom colors, and log file rotation.
Parameters:
| Name | Type | Mandatory | Position | Description | Default Value |
|---|---|---|---|---|---|
| Message | String | No | 0 | The message to log (can be empty or blank) | '' |
| Level | String | No | Named | Log level: DEBUG, INFO, WARNING, ERROR | INFO |
| LogPath | String | No | Named | Path to log file (creates directory if needed) | |
| NoConsole | Switch | No | Named | Disables console output (file only) | False |
| MaxFileSizeMB | Int | No | Named | Maximum log file size before rotation (1-1000 MB) | 10 |
| MaxLogFiles | Int | No | Named | Maximum number of rotated log files to keep (1-100) | 5 |
| ForegroundColor | String | No | Named | Custom console color (Black, DarkBlue, DarkGreen, DarkCyan, DarkRed, DarkMagenta, DarkYellow, Gray, DarkGray, Blue, Green, Cyan, Red, Magenta, Yellow, White). Alias: Color |
Outputs: None. Writes to console and/or file.
Default Colors by Level:
- DEBUG → Cyan
- INFO → White
- WARNING → Yellow
- ERROR → Red
Examples:
# Basic logging to console
Write-Log -Message "Application started"
# Log with custom color
Write-Log -Message "Success!" -ForegroundColor Green
# Using the Color alias
Write-Log -Message "Custom debug" -Level DEBUG -Color Magenta
# Log to file with rotation settings
Write-Log -Message "Important event" -LogPath "C:\Logs\app.log" -MaxFileSizeMB 5 -MaxLogFiles 3
# File only (no console output)
Write-Log -Message "Silent log" -LogPath "C:\Logs\app.log" -NoConsole
# Override ERROR default color
Write-Log -Message "Critical error" -Level ERROR -Color DarkRedNotes:
- Log file format:
YYYY-MM-DD HH:MM:SS [LEVEL] Message - Rotated files are named with
.1,.2, etc. suffixes (e.g.,app.log.1,app.log.2) - Custom colors override default level colors
Description: Retrieves the internal IP address of the system.
Parameters: None.
Outputs: PSCustomObject
| Property | Type | Description |
|---|---|---|
| AdapterName | String | Name of the network adapter |
| Description | String | Description of the network adapter |
| Status | String | Status of the network adapter (e.g., "Up") |
| IPv4Address | String | Internal IP address (only if status is "Up") |
| SubnetMask | String | Subnet mask in CIDR notation (Only if status is "Up") |
| Gateway | String | Default gateway (Only if status is "Up") |
| DnsServers | String[] | DNS server addresses (Only if status is "Up") |
| PrefixLength | Int | CIDR prefix length (Only if status is "Up") |
| IPConfiguration | String | IP configuration type (Only if status is "Up") |
Description: Retrieves the geographical location of a given public IP address.
Parameters:
| Name | Type | Mandatory | Value from Pipeline | Position | Description | Default Value |
|---|---|---|---|---|---|---|
| IPAddress | [String] | No | Yes | 0 | Public IP address to query | Public IPs to check |
Outputs: [PSCustomObject]
| Property | Type | Description |
|---|---|---|
| IPAddress | String | Public IP address |
| Country | String | Country name |
| CountryCode | String | Country code |
| ISP | String | Internet Service Provider |
Description: Retrieves the last boot time of the system.
Parameters: None.
Outputs: DateTime (Last boot time).
Description: Retrieves the public IP address of the system.
Parameters:
| Name | Type | Mandatory | Position | Description | Default Value |
|---|---|---|---|---|---|
| CopyToClipboard | Switch | No | Named | Copies the public IP address to clipboard | False |
Outputs: String (Public IP address).
Description: Retrieves the system uptime.
Parameters: None.
Outputs: TimeSpan (Duration since the last boot).
Description: Recursively removes empty folders from a specified directory.
Parameters:
| Name | Type | Mandatory | Position | Description | Default Value |
|---|---|---|---|---|---|
| Path | String | Yes | 0 | Path to the directory |
Outputs: [String] (List of removed empty folders).
Description: Generates a new random password.
Parameters:
| Name | Type | Mandatory | Position | Description | Default Value |
|---|---|---|---|---|---|
| Simple | Switch | Yes (ParameterSet) | Named | Generates a simple password (lowercase and numbers) | |
| Strong | Switch | Yes (ParameterSet) | Named | Generates a strong password (mixed case, numbers, symbols) | |
| Random | Switch | Yes (ParameterSet) | Named | Generates a random password with customizable options | |
| Length | Int | No | Named | Length of the password when using -Random | 12 |
| NoSymbols | Switch | No | Named | Excludes special characters from random passwords | False |
| PwnCheck | Switch | No | Named | Checks if the password has been exposed in data breaches | False |
| NumberOfPasswords | Int | No | Named | Number of passwords to generate | 1 |
| OutputPath | String | No | Named | Path to save passwords to a file | |
| CopyToClipboard | Switch | No | Named | Copies the password to clipboard | False |
| SleepTime | Int | No | Named | Delay between API calls in milliseconds | 100 |
| NoProgress | Switch | No | Named | Suppresses the progress bar display | False |
Outputs: String or String[] (Generated password(s)).
Description: Generates memorable passphrases by combining random words from a word list with customizable separators, case formatting, and optional numbers.
Parameters:
| Name | Type | Mandatory | Position | Description | Default Value |
|---|---|---|---|---|---|
| WordCount | Int | No | Named | Number of words to include in the passphrase (Alias: Words) | 3 |
| Separator | String | No | Named | Character to separate words ("-", "_", "None", ".", ",", "+", "=") | "-" |
| Case | String | No | Named | Case formatting ("Lowercase", "Uppercase", "Titlecase", "RandomCase") | "Titlecase" |
| ExcludeNumbers | Switch | No | Named | Excludes numbers from the passphrase | False |
| PwnCheck | Switch | No | Named | Checks if the passphrase has been exposed in data breaches | False |
| NumberOfPassphrases | Int | No | Named | Number of passphrases to generate (Alias: Count) | 1 |
| OutputPath | String | No | Named | Path to save passphrases to a file | |
| CopyToClipboard | Switch | No | Named | Copies the passphrase to clipboard | False |
| NoProgress | Switch | No | Named | Suppresses the progress bar display | False |
Outputs: String or String[] (Generated passphrase(s)).
Example:
New-Passphrase -WordCount 4 -Separator "_" -Case Uppercase
# Output: "CORRECT_HORSE_BATTERY_STAPLE42"Description: Converts a CIDR prefix to a subnet mask. e.g.
24 -> 255.255.255.0
Parameters:
| Name | Type | Mandatory | Position | Description | Default Value |
|---|---|---|---|---|---|
| PrefixLength | Int | Yes | 0 | CIDR prefix to convert (0-32) |
Outputs: String (Subnet mask in dotted-decimal notation).
Description: Converts a string to a URI-encoded (URL-encoded) format using EscapeDataString. Useful for encoding query parameters or path components for URLs.
Parameters:
| Name | Type | Mandatory | Position | Description | Default Value |
|---|---|---|---|---|---|
| inputString | String | Yes | 0 | The string to encode for URI use |
Aliases: URL
Outputs: String (URI-encoded string).
Description: Finds the longest common prefix string amongst an array of strings. Useful for comparing file paths or similar strings.
Parameters:
| Name | Type | Mandatory | Position | Description | Default Value |
|---|---|---|---|---|---|
| Strings | String[] | Yes | 0 | An array of strings to find common prefix among |
Outputs: String (Longest common prefix).
Example:
Get-LongestCommonPrefix -Strings @("flower", "flow", "flight")
# Output: "fl"Description: Sets the owner of a file or folder. Requires administrative privileges.
Parameters:
| Name | Type | Mandatory | Position | Description | Default Value |
|---|---|---|---|---|---|
| Path | String | Yes | 0 | Path to the file or folder | |
| Owner | String | No | 1 | Owner to set (in format DOMAIN\User or BUILTIN\Group) | BUILTIN\Administrators |
Outputs: None.
Description: Splits a string based on a specified substring, returning either the portion before or after the split point. Optionally returns both parts.
Parameters:
| Name | Type | Mandatory | Position | Parameter Set | Description | Default Value |
|---|---|---|---|---|---|---|
| InputString | String | Yes | 0 | Both | The string to split | |
| SplitBefore | String | Yes | Named | Before | Returns everything up to (not including) this substring | |
| SplitAfter | String | Yes | 1 | After | Returns everything up to and including this substring | |
| ReturnBoth | Switch | No | Named | Both | Returns both parts of the split | False |
Outputs: String or String[] (Split portion(s) of the input string).
Description: Tests if the current PowerShell session is running with administrative privileges. Works on both Windows PowerShell and PowerShell Core.
Parameters: None.
Outputs: Boolean ($true if running as administrator, $false otherwise).
This project is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License. Any installation from the PowerShell Gallery or manual distribution requires explicit acceptance of the license terms.