开发者

Where does Windows PowerShell set $profile?

开发者 https://www.devze.com 2023-04-10 03:55 出处:网络
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

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?


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 like C:\Windows\System32\WindowsPowerShell\v1.0\profile.ps1

Related question: Is it possible to change the default value of $profile to a new value?


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

junction.exe "$HOME\Documents\WindowsPowerShell" 'C:\POSH'


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).


By default $Profile/$Home/$PSModulePath are all within the registry... normally under

  • HKEY_CURRENT_USER\Volatile Environment for User environment variables
  • HKEY_CURRENT_USER\Environment for System environment variables
  • HKEY_CURRENT_USER\Software\Microsoft\Windows\Explorer\User Shell Folders

and elsewhere!

0

精彩评论

暂无评论...
验证码 换一张
取 消