Enables a one-and-done global PowerShell profile for all installed PS editions (e.g. Desktop, ISE, Core), as each PS profile is seperate by default.
OnePowerShellProfile essentially generates duplicate profile files for each PS edition installed on the machine -- based off the content of the Public.ps1
and Private.ps1
files provided in this module.
Profiles can be saved and archived
Install-Module -Name OnePowerShellProfile
via https://www.powershellgallery.com/packages/OnePowerShellProfile
git clone https://github.com/alexchong/OnePowerShellProfile.git
Import-Module /path/to/OnePowerShellProfile.psm1
- PowerShell 5.1 or later
Invoke-ProfileConfiguration -Type Public # Add profile stuff here (e.g. aliases, environment paths)
Set-Profile -ArchiveCurrentProfule $True # Save your existing profile in case you want to revert!!!!
Invoke-ProfileConfiguration
# Modify Public.ps1 or Private.ps1 profile templates
[-Type {"Public" | "Private"} <string>]
Set-Profile
# Includes Private.ps1 content into global OnePowerShellProfile
[-IncludePrivate {$True | $False} = $False <boolean>]
# Snapshot && archive the current profile (useful if you want to revert)
[-ArchiveOldProfile {$True | $False} = $False <boolean>]
It builds a global PowerShell profile, and distributes it across any installed PS editions (i.e. Desktop, ISE, Core).
I frequently switch between different PowerShell editions, and this helps me maintain an overall persistent profile environment.
Public.ps1
and Private.ps1
are the two source files that are concatenated into the global PowerShell profile.
In the event you want to export out a global profile to a different account or computer, you can do the following:
# 1. Build a new profile without sourcing Private.ps1
Set-Profile -IncludesPrivate $False -ArchiveOldProfile $True
# 2. Find any *profile.ps1 generated from the following message
# => [DONE] Updated /path/to/Microsoft.PowerShell_profile.ps1
Using Set-Profile
, if -ArchiveOldProfile
option is set to $True
, then it will generate a message like this:
[DONE] Updated /path/to/Microsoft.PowerShell_profile.ps1
From there, you can navigate to the provided path.
I have not included this functionality yet, but plan to if I eventually need to, or if requested.