Powershell installing modules into OneDrive folder

Hi,

I noticed that Powershell 7.2.5 installs its modules and other scripts into my OneDrive folder, specifically C:\Users\myuser\OneDrive\Documents\PowerShell. This is undesirable, as the subfolder can become quite large and can take up the majority of my OneDrive space.

How do i prevent this from happening? I checked the PSModulePath environmental variable and it doesn’t contain a OneDrive location.

Gabriel,
Welcome to the forum. :wave:t4:

… by providing the -Scope AllUsers instead of -Scope CurrentUser when using Install-Module

… but I’d bet it contains your profile path, doesn’t it? And that will be redirected and synchronized with your OneDrive folder.

Hi Olaf,

No, the env variable doesn’t contain any profile path, see the screenshot:

I will try with -Scope AllUsers next time, thanks for the suggestion. Does it work for Update-Module too?

I’d expect that an installed module will be updated in the folder it’s installed in.

I actually wasn’t sure about that … I should have checked before. Sorry.

:+1:t4: