Microsoft’s left hand apparently does not know what it’s right is doing, so I am writing a script that automates the correct setup of Powershell $profiles on a clean Windows install.
Currently, my script removes OneDrive and sets Registry Values so that Powershell’s global automatic variable naturally points to Microsoft’s recommendations:
C:Users{username}DocumentsWindowsPowershell
for WindowsPowershell(5.1)
C:Users{username}DocumentsPowershell
for Powershell(7.4+)
This I already fixed, as the $profile is set specifically to what Microsoft advises against by default (by OneDrive).
However, now I have a new problem, of the same ilk, regarding the 5.1 $profile:
$profile.CurrentUserCurrentHost
and
$profile.CurrentUserAllHosts
are correct.
$profile.AllUsersCurrentHost == C:WindowsSystem32WindowsPowerShellv1.0Microsoft.PowerShell_profile.ps1
$profile.AllUsersAllHosts == C:WindowsSystem32WindowsPowerShellv1.0profile.ps1
Why is this the case? Microsoft specifically points to: C:Program FilesWindowsPowerShellModules
as the correct path to add modules for AllUsers in their PsModulePath/$Profile documentation, so why does $profile.AllUsers default to this value (yet again against their own recommendations, much like the behavior of OneDrive). What is the point of even having an environment auto-var if it can’t seem to set itself correctly to spec?
Should I force the $profile value to point to the recommended path, so that $profiles can be correctly installed by script, when AllUsers is desired?