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

308 views Asked by At

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.

1

There are 1 answers

0
mklement0 On BEST ANSWER

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:

  • -Scope CurrentUser vs. -Scope AllUsers (which is the invariably implied default in Windows PowerShell) in PowerShell 7+ allows you an abstract choice between user-level and all-users locations, but you do not get to control what specific directories are targeted as a result.

    • Indeed, it appears that you can not control the target directories via $env:PSModulePath.
  • Specifically:

    • With -Scope CurrentUser (the default in v7+):

      • Updates to any modules - whether third-party or not - are stored in the following user-level locations, in folders that parallel the actual module folders:
        • Windows: "$(Split-Path $PROFILE)\Help"
        • Unix-like platforms: "$HOME/.local/share/powershell/Help"
    • With -Scope AllUsers (which typically requires _elevation):

      • Updates to the help content of modules that are either built into or ship with PowerShell are made to subfolders of $PSHOME, PowerShell's installation folder.

      • Third-party modules that support updatable help content are updated in-place, irrespective of where they're installed, assuming they're discoverable via $env:PSModulePath.


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