Windows PowerShell 在哪里设置 $profile?
我想移动我的默认“My Documents\WindowsPowerShell”文件夹。但是,当我尝试这样做时,PowerShell 当然找不到 $profile。是否有一个文件或其他内容可以编辑以将 PowerShell 指向不同的启动文件夹?
I would like to move my default "My Documents\WindowsPowerShell" folder. However, when I try this, PowerShell of course can't find $profile. Is there a file or something that I can edit to point PowerShell to a different startup folder?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我可以建议您在文件
$profile.AllUsersAllHosts
$profile.AllUsersAllHosts
中获取包含您的个人资料内容的文件,类似于
C: \Windows\System32\WindowsPowerShell\v1.0\profile.ps1
相关问题:是否可以更改$profile 的默认值是否为新值?
What I can suggest is that you dot source the file having the content of your profile in the file
$profile.AllUsersAllHosts
$profile.AllUsersAllHosts
is something likeC:\Windows\System32\WindowsPowerShell\v1.0\profile.ps1
Related question: Is it possible to change the default value of $profile to a new value?
您可以使用 Sysinternals 中的 junction.exe 来制作
WindowsPowershell
目录 指向另一个位置(但不是网络驱动器)的符号链接。如果您想将配置文件脚本存储在
C:\POSH
中,则可以执行此操作You could use junction.exe from Sysinternals to make the
WindowsPowershell
directory a symbolic link to another location (but not a network drive).You could do this if you wanted to store the profile scripts at
C:\POSH
据我所知你不能这样做。用户配置文件位置始终位于“我的文档\WindowsPowerShell”下,您唯一的选择是重新定位文档文件夹(文件夹重定向)。
As far as i know you can't do that. The user profile location is always under 'My Documents\WindowsPowerShell' and your only option is to relocate your documents folder (folder redirection).
默认情况下,
$Profile/$Home/$PSModulePath
均位于注册表中...通常位于HKEY_CURRENT_USER\Environment
HKEY_CURRENT_USER\Software\Microsoft\Windows\Explorer\User Shell Folders
和其他地方!
By default
$Profile/$Home/$PSModulePath
are all within the registry... normally underHKEY_CURRENT_USER\Volatile Environment
for User environment variablesHKEY_CURRENT_USER\Environment
for System environment variablesHKEY_CURRENT_USER\Software\Microsoft\Windows\Explorer\User Shell Folders
and elsewhere!