r/PowerShell • u/stumper66 • 4d ago
Question PowerShell 7.7 - All users profile script location
Starting with PowerShell 7.7 it is now a windows app and if you install it with Add-AppxPackage, then it will live in "C:\Program Files\WindowsApps\Microsoft.PowerShell_7.7.0.0_x64__8wekyb3d8bbwe"
On previous versions I had profile.ps1 live in "C:\Program Files\PowerShell\7"
However not only do I suspect the bin directory will change with each new version, it is now read-only for everything except system, you can't put any files in there without hacking it with system privileges.
Where do they expect us to put all user scripts now?
4
u/muddermanden 4d ago
It depends, but just stick to the standard locations. But what does the binary location have to do with the user profile location?
1
u/stumper66 4d ago
Just need a script to run for each user. The binary path has always been the only location for this.
13
u/cloudAhead 4d ago
My read is that Microsoft is very aware of the limitations they're shipping and see this as a stepping stone to 7.8 LTS. Release this, get feedback, and buy a year to resolve the bigger issues. There's really no must have in 7.7, so folks are safe staying on 7.6 LTS.
1
u/root-node 4d ago
2
u/stumper66 4d ago
It says to use $PSHOME\Profile.ps1 which is the ugly path I mentioned. Are you expected to copy a file to there under system context? Also what happens when 7.7.1 comes out, you need to find out the new path and migrate the startup script there?
3
u/TheProle 4d ago
Make that profile be nothing but a function that loads your profile from somewhere else (even a GitHub repository)
1
u/BlackV 4d ago edited 4d ago
On previous versions I had profile.ps1 live in "C:\Program Files\PowerShell\7"
the was the ALL users profile, not your profile
I'd imagine it actually looks something like
$profile | select *
AllUsersAllHosts : C:\Program Files\PowerShell\7\profile.ps1
AllUsersCurrentHost : C:\Program Files\PowerShell\7\Microsoft.PowerShell_profile.ps1
CurrentUserAllHosts : C:\Users\<username>\OneDrive\Documents\PowerShell\profile.ps1
CurrentUserCurrentHost : C:\Users\<username>\OneDrive\Documents\PowerShell\Microsoft.PowerShell_profile.ps1Edit: sorry dumb reading failure store version
4
u/stumper66 4d ago
Not anymore. It is now this. Not even administrators can write to that directory.
AllUsersAllHosts : C:\Program Files\WindowsApps\Microsoft.PowerShell_7.7.0.0_x64__8wekyb3d8bbwe\profile.ps1 AllUsersCurrentHost : C:\Program Files\WindowsApps\Microsoft.PowerShell_7.7.0.0_x64__8wekyb3d8bbwe\Microsoft.PowerShell_profile.ps1
2
u/jibbits61 4d ago
Argh. Not only do I have to pull back some accidental upgrades to 7.7.0, we have this crap.
I set the environmental variable to LTS (systemwide) and it didn’t honor it.
Gpo here I come…happy to take other suggestions, I want to make this stupid easy so it so it stays on LTS only. 💩💩💩
1
u/ewild 2d ago
The same occurs when installing PowerShell with winget:
winget install --id Microsoft.PowerShell --source winget
Traditional installation of the latest PowerShell via winget is no longer possible (the MSI installer is no longer provided, so the command below installs 7.6.10 max, not 7.7.0):
winget install --id Microsoft.PowerShell --source winget --installer-type wix
Does it make sense now to install 7.6.10 and then update it with PowerShell-7.7.0-win-x64.zip (and with PowerShell-7.*-win-x64.zip on)?
Installing 7.7.0 this way (7.6.10 > zip > 7.7.0) gives:
$profile | select *
AllUsersAllHosts : C:\Program Files\PowerShell\7\profile.ps1
AllUsersCurrentHost : C:\Program Files\PowerShell\7\Microsoft.PowerShell_profile.ps1
CurrentUserAllHosts : <OneDrive>\Documents\PowerShell\profile.ps1
CurrentUserCurrentHost : <OneDrive>\Documents\PowerShell\Microsoft.PowerShell_profile.ps1Auto-update will no longer be available with this approach.
51
u/jborean93 4d ago •
Unfortunately it's a known limitation, you can't edit anything in
$PSHomeas they are immutable for MSIX packages, and the work to enable a custom location never landed in 7.7 (see enterprise configuration https://github.com/PowerShell/PowerShell/issues/27565#issuecomment-6802573646).You have a few options:
Use a per user profile rather than all users
Stick with 7.6.x, it still has an .msi and is an LTS
Upgrade to 7.7.x but use the .zip and extract to
C:\Program Files\PowerShell\7(or any location really)Use a 3rd party .msi, or build your own, from the .zip assets
None are great but not too much you can do