On Windows, not counting ISE or x86, there are four (4) profile scripts.
AllUsersAllHosts @ C:\Program Files\PowerShell\6\profile.ps1
AllUsersCurrentHost @ C:\Program Files\PowerShell\6\Microsoft.PowerShell_profile.ps1
CurrentUserAllHosts @ C:\Users\lit\Documents\PowerShell\profile.ps1
CurrentUserCurrentHost @ C:\Users\lit\Documents\PowerShell\Microsoft.PowerShell_profile.ps1
On Linux with pwsh 6.2.0 I can find only two locations.
CurrentUserAllHosts @ ~/.config/powershell/Microsoft.PowerShell_profile.ps1
CurrentUserCurrentHost @ ~/.config/powershell/profile.ps1
Are there any "AllUsers" profile scripts on Linux? If so, where are they?
tl;dr (also applies to Windows):
The conceptual about_Profiles help topic describes PowerShell's profiles (initialization files).
The automatic
$PROFILEvariable contains a string that is the path of the initialization file for the current user and the current PowerShell host environment (typically, the terminal a.k.a console).Additional profile files are defined - along the dimensions of (a) all-users vs. current-user and (b) all host environments vs. the current one - which are exposed via properties that the
$PROFILEstring variable is decorated with, which makes them nontrivial to discover - see below.None of the profile files exist by default, and in some case even their parent directories may not; the bottom section of this answer shows programmatic on-demand creation and updating of the
$PROFILEfile.Olaf provided the crucial pointer in comment:
shows all profile file locations, whether or not the individual profile files exist.
E.g., on my Ubuntu machine with PowerShell installed in
/home/jdoe/.powershell, I get:Note the presence of the
[string]type's nativeLengthproperty, which you could omit if you used$PROFILE | select *host*instead.That you can get the profile locations that way is not obvious, given that
$PROFILEis a string variable (type[string]).PowerShell decorates that
[string]instance withNotePropertymembers reflecting all profile locations, which is whyselect(Select-Object) is able to extract them.Outputting just
$PROFILE- i.e. the string value - yields/home/jdoe/.config/powershell/Microsoft.PowerShell_profile.ps1, i.e. the same path as itsCurrentUserCurrentHostproperty, i.e. the path of the user-specific profile file specific to the current PowerShell host environment (typically, the terminal aka console).[1]You can verify the presence of these properties with reflection as follows, (which reveals their values too):
This means that you can also use regular property access and tab completion to retrieve individual profile locations; e.g.:
Convenience functions for getting profile locations and opening profiles for editing:
The code below defines:
Get-Profileenumerates profiles, showing their location and whether they exist on a given machine.Edit-Profileopens profile(s) for editing (use-Forceto create them on demand); note that modifying all-user profiles typically requires running as admin.[1] PowerShell considers the current-user, current-host profile the profile of interest, which is why
$PROFILE's string value contains that value. Note that in order to decorate a[string]instance with note properties,Add-Memberalone is not enough; you must use the following idiom:$decoratedString = $string | Add-Member -PassThru propName propValue- see theAdd-Memberhelp topic.