I would like to know how to change my the location my $profile variable points to.

PS H:\> $profile

H:\ is a network share, so when I create my profile file, and load powershell I get the following:

Security Warning Run only scripts that you trust. While scripts from the Internet can be useful, this script can potentially harm your computer. Do you want to run H:\WindowsPowerShell\Microsoft.PowerShell_profile.ps1? [D] Do not run [R] Run once [S] Suspend [?] Help (default is "D"):

According to Microsoft, the location of the $profile is determined by the %USERPROFILE% environment variable. This is not true:

PS H:\> $env:userprofile

For example, I have an XP machine working how I want:

PS H:\> $profile
C:\Documents and Settings\username\My Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1
PS H:\> $env:userprofile
C:\Documents and Settings\username
PS H:\> $env:homedrive
PS H:\> $env:homepath

Here's the same output from the Vista machine where the $profile points to the wrong place:

PS H:\> $profile
PS H:\> $env:userprofile
PS H:\> $env:homedrive
PS H:\> $env:homepath

Since $profile isn't actually determined by %USERPROFILE% how do I change it? Clearly anything that involves changing the homedrive or homepath is not the solution I'm looking for.

  • Do you have roaming profile or any sort of my documents folder redirection (by gpo)?
    – Shay Levy
    Oct 28, 2010 at 9:05

5 Answers 5


You might also check out this post on Stack Overflow. The best solution offered so far (to my almost identical question) is to change $profile.AllUsersAllHosts to "dot source" another file of your own choosing.

I've seen nothing so far to indicate you can change the default value of $profile itself.

  • 1
    This is a workaround to many cases, but it's not really an answer to OP's needs.
    – villasv
    Feb 18, 2017 at 15:55

As @FrankMerrow posted, on this Stack Overflow question you will find the answer, but the correct is the one from Neck Beard, I'll copy it here.

As @woter324 points out issuing $profile | select * will show you the paths from where PowerShell gets profiles. As stated in the MS documentation:

The profiles are listed in precedence order. The first profile has the highest precedence.

<username>$> $profile | select *

AllUsersAllHosts       : C:\Windows\System32\WindowsPowerShell\v1.0\profile.ps1
AllUsersCurrentHost    : C:\Windows\System32\WindowsPowerShell\v1.0\Microsoft.PowerShell_profile.ps1
CurrentUserAllHosts    : C:\Users\<username>\Documentos\WindowsPowerShell\profile.ps1
CurrentUserCurrentHost : C:\Users\<username>\Documentos\WindowsPowerShell\Microsoft.PowerShell_profile.ps1
Length                 : <will vary>

Those above are mine's, I supose you get something like

CurrentUserAllHosts    : H:\WindowsPowerShell\profile.ps1
CurrentUserCurrentHost : H:\WindowsPowerShell\Microsoft.PowerShell_profile.ps1

In order to edit those paths you have two ways

Via regedit

Edit the key with name Personal that you will find under HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders

Via PowerShell

I didn't test this one, in the linked thread a user says it has to be tweaked in order to work but I supose it should be easy to get through.


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

Either way you have to reboot Power Shell (or windoes terminal) for this to take effect. You can then check again with $profile | select *.


I was having a similar issue using Windows XP and Windows 8 from within a VMware Fusion virtual machine:

PS C:> $profile
\\vmware-host\Shared Folders\<user>\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1

Once I stopped 'Desktop' mirroring (I kept the shared folders), the problem was resolved:

PS C:> $profile
C:\Documents and Settings\Administrator\My Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1
  • Same issue here. For reference, the setting is under Virtual Machine / Settings... / Sharing / Mirrored Folders.
    – ngm
    Jan 26, 2015 at 11:43
  • Good catch. I had to uncheck "Documents" mirroring, haven't even had Desktop checked. I guess any mirroring causes problems. Mar 28, 2016 at 15:28

I'm on Windows 10 and was having the same problem. I was able to fix it by changing the Location in Document Properties.

My $profile was being referenced by UNC path (ex. \\server\path\to\my\document\WindowsPowerShell\Microsoft.PowerShell_profile.ps1). When Powershell tried to execute this, I got the security warning.

To fix this:

  1. Create a mapped drive to the network folder.
  2. Go to This PC and right-click the Documents folder and select Properties.

    Document folder

  3. Update Location to Mapped Drive Path

    Location Setting

  4. Click OK or apply.


I had the same issues os the OP and due to a heavily locked-down environment, I am unable to change the PS Execution Policy, and moving my whole profile from a DFS network share was not an option, but I need a $Profile.

The profile is read from several places, discovered by:

$profile | select *

It should return the locations of your profiles, relative to the version of PowerShell you are running.

You should be able to place it inside any one of those locations. There is an order a preference - but I can't remember what it is. More importantly, it gives you a choice of local locations, meaning you won't hit the issue that prevents scripts running from UNC paths.

For me, I was able to place my Microsoft.VScode_profile.ps1 file inside C:\Program Files\PowerShell-7.0.2-win-x64\ (Where I run PS 7.0.2 from).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.