3

I've come across this (archived) Blog post on PowerShell profiles. In the learning docs I read a note that the scripts should not be stored on OneDrive. Users probably will use the standard settings of OneDrive backing up Documents, Desktop and Pictures to OneDrive. I'm quite confused now. Are these locations in blog and learning still accurate as of 2024?

What location should I use for what type of scripts or modules?

theking2
  • 519

2 Answers2

2

The blog post you have found is from 2012 and refers to an older version of Windows. While most of it is still correct, the profile folders are not up to date.

The article you found is more recent from 2023, so is to be taken seriously. The "Current user, Current Host" profile location is said to be in $HOME\Documents\PowerShell, which refers to C:\Users\USER-NAME\Documents\PowerShell.

If you install OneDrive, it will by default backup the Documents folder, by relocating it into the OneDrive sync folder and leaving only a pointer to it in C:\Users\USER-NAME.

This means that, if you have accepted the default setup of OneDrive, your PowerShell profiles are by default synced to OneDrive, but your reference is to a local folder. The profiles will be backed up to OneDrive, but the reference should stay to the local disk, not to the OneDrive folder in the cloud, to avoid problems when there is no internet connection.

harrymc
  • 498,455
0

The answer from harrymc is mostly right, except Microsoft has changed things and moves things around and doesn't update their documentation.

Try this to understand your Powershell "profile" scripts:

PS C:\Users\you> $PROFILE | select-object *

The output will be something like:

AllUsersAllHosts       : C:\Program Files\PowerShell\7\profile.ps1
AllUsersCurrentHost    : C:\Program Files\PowerShell\7\Microsoft.PowerShell_profile.ps1
CurrentUserAllHosts    : C:\Users\you\OneDrive\Documents\PowerShell\profile.ps1
CurrentUserCurrentHost : C:\Users\you\OneDrive\Documents\PowerShell\Microsoft.PowerShell_profile.ps1
Length                 : 77

This tells you where the profiles are, for you.

Cheeso
  • 2,159