Change the Powershell $profile directory
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.
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
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).