Powershell $PROFILE 变量指向错误的位置。它设置的 $PROFILE 变量在哪里?

ari*_*dar 1 powershell powershell-core

对我的机器进行一些更改后,Powershell 失败,因为 $PROFILE 变量指向与以前不同的位置,即它设置为

C:\Powershell\Microsoft.PowerShell_profile.ps1
Run Code Online (Sandbox Code Playgroud)

代替

C:\Users\user\Documents\Powershell\Microsoft.PowerShell_profile.ps1
Run Code Online (Sandbox Code Playgroud)

这会导致诸如找不到已安装模块等问题。所以我的问题是Powershell如何设置$PROFILE的值?可以改变吗?

ari*_*dar 5

解决了。原来问题发生之前,$PROFILE已经指向了OneDrive中的Documents文件夹,即

C:\Users\user\OneDrive\Documents\PowerShell\Microsoft.PowerShell_profile.ps1
Run Code Online (Sandbox Code Playgroud)

当我启用文档备份到 OneDrive 并重新登录时,$PROFILE 又回到了正确的位置。看来,如果 Powershell 在“文档”或 $HOME 下找不到配置文件位置,则它默认为路径 C:\Powershell。但是我不确定 - 如果对这种行为有明确的规范就好了。