Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to prevent Powershell Modules being installed into OneDrive

Tags:

powershell

My $env:PSModulePath has ended up containing OneDrive:

C:\Users\jack\OneDrive\Documents\PowerShell\Modules;C:\Program Files\PowerShell\Modules;c:\program files\powershell\7\Modules;C:\Program Files\WindowsPowerShell\Modules;C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules

But I don't want all my Modules being synced to the cloud.

According to the docs:

The user-specific CurrentUser location on Windows is the PowerShell\Modules folder located in the Documents location in your user profile ... Microsoft OneDrive can also change the location of your Documents folder.

So that explains how the Modules ended up there. But how do I fix it?

I can modify $env:PSModulePath but this will only allow pwsh to find more modules I think. It won't change the default path for installing new modules for CurrentUser.

P.S. I face the same problem with the Update-Help when it saves help locally... OneDrive :-(

like image 642
Jack Ukleja Avatar asked Mar 31 '20 00:03

Jack Ukleja


1 Answers

Perhaps the information in this thread on Reddit, could be of help.

Here's a snip from one of the answers, talking about excluding certain folders:

You can accomplish this by opening the OneDrive settings on your PC.

  1. Go to OneDrive settings
  2. Click the Account tab
  3. Click "Choose Folders" and then cherry pick the folders you want to exclude.
like image 182
Martin Sandgaard Rasmussen Avatar answered Nov 15 '22 10:11

Martin Sandgaard Rasmussen