r/PowerShell • • 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?

77 Upvotes

24 comments sorted by

51

u/jborean93 4d ago • Bravo

Where do they expect us to put all user scripts now?

Unfortunately it's a known limitation, you can't edit anything in $PSHome as 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

15

u/stumper66 4d ago

This answers my question.

2

u/Incrediblecodeman 4d ago

I love it when Reddit provides

10

u/warren_stupidity 4d ago

Use a gpo that sticks a standard profile in the CurrentUserAllHossts or CurrentUserCurrentHost directory for each user.

But holy shit, they are getting even further away from being able to remove psh5.1 from systems. That bug list is magnificent. Let's just release this mess that breaks a whole lot of stuff, and all we have is concepts of a plan for fixing the mess we are making.

5

u/Thotaz 4d ago

Their definition of "Blocker" is certainly unique in the industry.

2

u/rswwalker 3d ago

Ugh! Why doesn’t MS realize admins don’t need no stinking msstore, just put the MSI in winget with the option to install per-user or per-machine and we’re all happy.

4

u/muddermanden 4d ago

https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_profiles?view=powershell-7.6#profile-types-and-locations

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.

2

u/Flettys 1d ago

That would be acceptable if we were on version 0.x.

After twenty years and massive worldwide use, releasing a knowingly-broken version to hit an arbitrary internal target is insane.

7

u/Flettys 4d ago

No PSModulePath release in 7.7 either.

That's a nasty list of known issues, and as-always the unknown issues must be 10x or more.

3

u/Alaknar 4d ago

No PSModulePath release in 7.7 either.

Wait, what? How does it import modules then?

2

u/Flettys 3d ago

Same as ever.

The planned change (now for 7.8) is to move the default user-scoped path from My Documents -> LocalAppData (blame OneDrive KFM for breaking My Documents in the first place) and make it more easily configurable.

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)

2

u/Alaknar 4d ago

While that's a neat workaround for some issues, it doesn't help solving the issue of every update changing the path and rewriting the profile.

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.ps1

Edit: 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

3

u/BlackV 4d ago

Apologies reading failure, yes, its always been that way with the store version, known limitation

3

u/ftw_dan 3d ago

Msix is cancer

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/BlackV 4d ago edited 4d ago

Where do they expect us to put all user scripts now?

this bit, what do you mean by "all users scripts"?

$profile.AllUsersAllHosts would run for all users when they launch powershell, but wouldn't all user script be in C:\Program Files\PowerShell\Scripts still ?

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.ps1

Auto-update will no longer be available with this approach.