Skip to content
StefanGrevePublic

About

My PowerShell Profile. Home to the PowerTools module.

Topics

Resources

Stars

11 stars

Watchers

2 watching

Forks

Repository files navigation

PowerShell Profile

Unit Test Publish Module PowerShell Gallery Version PowerShell Version GitHub License

The project contains the source code of my PowerShell profile as well as the PowerTools module. You need version 7.4 or higher to use this project.

The profile and the module ship independently: profile.ps1 is installed straight from this repository and picks up changes as soon as they land here, whereas PowerTools follows its own versioned release schedule on the PowerShell Gallery.

Setup

Run install.ps1 as administrator to download profile.ps1, symlink it to your selected $PROFILE, and install the PowerTools module (which provides the remaining scripts):

irm "https://raw.githubusercontent.com/StefanGreve/profile/master/install.ps1" | iex

Tip

Set your ExecutionPolicy to Unrestricted in order to run the installer script. Note that this configuration step only applies to Windows users. On non-Windows computers, Unrestricted is already the default ExecutionPolicy and cannot be changed (see also: About Execution Policy)

Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy Unrestricted

Settings Documentation

The profile reads its configuration from a profile.config.json file that lives next to profile.ps1 (install.ps1 downloads a default copy for you). Edit that file to customize the profile; documentation for the configuration options is provided in the form of a JSON schema file.

{
    "$schema": "https://raw.githubusercontent.com/StefanGreve/profile/master/profile.config.schema.json",
    "DefaultCulture": "en-US",
    "DefaultEncoding": "utf8",
    "DotSourceDirectory": "~/Documents/Scripts",
    "EnableClassicProgressbar": true,
    "Modules": [ "PowerTools" ],
    "Prompt": {
        "EnableBatteryStatus": true,
        "EnableGitUserName": true,
        "EnableTimestamp": true
    },
    "RegisterNativeCompletions": [ "gh", "pip", "winget" ]
}

Note

Completion scripts are cached, so the generator only runs on the first profile load and whenever the tool's executable changes. Later launches dot-source the cached script, which removes the subprocess cost but not the parse cost: very large completion scripts (notably deno and uv) still add measurable load time on every start.

Note

To enable tab completion for dotnet and .NET-based CLI programs, optionally install the following:

# install an LTS .NET SDK, e.g. version 10
winget install --id "Microsoft.DotNet.SDK.10"
dotnet tool install --global "dotnet-suggest"

Tip

The shipped profile.config.json references a JSON schema for editor validation and completion. Visual Studio Code downloads remote schemas only from trusted domains, so add the following to your VS Code settings.json (User or Workspace) to allow it:

"json.schemaDownload.trustedDomains": {
    "https://raw.githubusercontent.com/": true
}

Platform Support

The module targets Windows first, but most Cmdlets run cross-platform. The table below summarizes which operating systems each exported Cmdlet supports. Cmdlets that are unsupported on a platform throw a NotImplemented error rather than failing silently. The PowerShell profile (profile.ps1) itself is supported on all major platforms.

Cmdlet Windows macOS Linux
Get-Battery ✅ ✅ ❌
Get-Definition ✅ ✅ ✅
Get-EnvironmentVariable ✅ ⚠️ ⚠️
Get-FileCount ✅ ✅ ✅
Get-FileSize ✅ ✅ ✅
Get-MaxPathLength ✅ ✅ ✅
Get-RandomPassword ✅ ✅ ✅
Get-Salt ✅ ✅ ✅
Get-StringHash ✅ ✅ ✅
Install-Certificate ✅ ❌ ❌
Install-Font ✅ ✅ ❌
Invoke-TextToSpeech ✅ ✅ ❌
Invoke-XKCD ✅ ✅ ✅
Remove-EnvironmentVariable ✅ ⚠️ ⚠️
Set-EnvironmentVariable ✅ ⚠️ ⚠️
Set-MonitorBrightness ✅ ✅ ❌
Set-PowerState ✅ ✅ ✅
Set-SystemTheme ✅ ✅ ❌
Start-Timer ✅ ✅ ✅
Stop-LocalServer ✅ ✅ ✅
Test-Elevation ✅ ✅ ✅

Warning

Some Cmdlets offer only partial support on certain platforms: they run but with reduced functionality or platform-specific limitations.

Developer Notes

Set up the development environment. This restores the local .NET tools and installs the Husky Git hooks:

./scripts/init.ps1

Use the dev.ps1 script to build and load a local development version of the PowerTools module. It unloads the currently installed module, builds a local 0.0.0 version, and re-imports it from source.

./scripts/dev.ps1

New releases are published to the PowerShell Gallery by the Publish Module GitHub Actions workflow, which takes the version number as an input.

Run the unit tests with the test.ps1 script. Pass -Build to rebuild the module before the test run.

./scripts/test.ps1 -Build

See also Types.ps1xml and Format.ps1xml files for editing ps1xml files.

About

My PowerShell Profile. Home to the PowerTools module.

Topics

Resources

Stars

11 stars

Watchers

2 watching

Forks

Releases

Used by

Contributors

Languages