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

前端 未结 8 1517
予麋鹿
予麋鹿 2020-12-10 01:18

So I would rather not create my profile file here:

C:\\Users\\fmerrow\\Documents\\WindowsPowerShell\\Microsoft.PowerShell_profile.ps1

I mea

相关标签:
8条回答
  • 2020-12-10 01:53

    You can also put your profile file here

    C:\Windows\System32\WindowsPowerShell\v1.0\profile.ps1
    

    If you want to have a separated location for all your profiles and scripts, you can modify your profile.ps1 file above as

     $profile = "NewLocation\profile.ps1"
    . $profile
    

    Make sure what type of profile you use, see details here

    https://technet.microsoft.com/en-ca/library/dd819434.aspx

    0 讨论(0)
  • You can change your $Profile.CurrentUser* paths by changing your personal folder path Environment.GetFolderPath(Environment.SpecialFolder.Personal)

    Either via regedit

    HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders

    Under the Name column select Personal and chage the value to where you want your profile.

    Or via PowerShell

    New-ItemProperty 'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders' Personal -Value 'Your New Path Here' -Type ExpandString -Force

    You have to reboot for this to take effect.

    0 讨论(0)
提交回复
热议问题