windowspowershellpowershell-7

Set the Location where Update-Help Installs Help Files in PowerShell?


I just installed PowerShell 7 and ran Update-Help -Force -UICulture en-us to install all the help files. This all works well enough, only I then noticed that it installed them in C:/Users/<me>/OneDrive/Documents/PowerShell/Help. I do not want the files in OneDrive, I want them in the pwsh installation folder.

First, I figured that changing PSModulePath would probably also affect where help files are stored. I checked $env:PSModulePath (in the pwsh window) and found that, indeed, the first entry is C:/Users/<me>/OneDrive/Documents/PowerShell/Modules. The system value for PSModulePath is C:\Program Files\WindowsPowerShell\Modules;C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules;. I tried changing the it and I tried editing powershell.config.json, but neither will change anything about the fact that "PS7 User, System, and $PSHOME paths" are prepended to the variable when pwsh starts up.

I tried just manually setting PSModulePath and then running Update-Help from within pwsh, but that doesn't work either. After this, I ran gci $env in that same pwsh windows and the only places where C:/Users/<me>/OneDrive/Documents shows up at all are the OneDrive and OneDriveCommercial variables. These are also the only system environment variables that reference C:/Users/<me>/OneDrive/Documents. So apparently, PowerShell is explicitly configured to use OneDrive as the first location for installing modules? How else could this come about? the pwsh start program is an executable, so I can't really look inside it either.

I've also tried letting it install the help files in my OneDrive folder, then copying them to various locations and <entry>/Modules, <entry>/en-US locations on the PSModulePath. But wherever I put them, once they are gone from the OneDrive folder, get-help get-help says the usual "Get-Help cannot find the Help files for this cmdlet on this computer. It is displaying only partial help." message.

I'm starting to think that there is actually no relation at all between the PSModulePath and where the help files are stored and searched for.

There seem to be various options for determining where Update-Help gets the help files, but none for deciding where to save them.

So yeah: how do I decide where help files are installed, if changing PSModulePath is not it? I'll settle for some workaround for now, too.


Solution

  • I want them in the pwsh installation folder.

    Pass -Scope AllUsers to Update-Help (which works in PowerShell (Core) 7+ only) to avoid targeting user-specific locations.

    Note that this option typically[1] requires elevation (running with admin privileges).


    Note:


    [1] Given that it's possible to install PowerShell (Core) in a user-specific location, elevation isn't necessary in that case.