lit
lit

Reputation: 16266

How can I change the profile related path variables?

The organization has changed my "home" server location and has it configured so that I cannot have files in %USERPROFILE%\Documents. However, when I start PowerShell, it still points to the previous server for some significant variables. How do I change this?

PROFILE        \\OLDSERVER\USERS\lit\My Documents\WindowsPowerShell\Microsoft.PowerShell_prof...
PSCommandPath  \\OLDSERVER\USERS\lit\My Documents\WindowsPowerShell\profile.ps1
PSScriptRoot   \\OLDSERVER\USERS\lit\My Documents\WindowsPowerShell

This is on PSVersion 5.0.10586.117 on Windows 7.

PS H:\My Documents> $profile | get-member -type noteproperty

Name                   MemberType   Definition
----                   ----------   ----------
AllUsersAllHosts       NoteProperty string AllUsersAllHosts=C:\Windows\System32\WindowsPowerShell\v1.0\profile.ps1
AllUsersCurrentHost    NoteProperty string AllUsersCurrentHost=C:\Windows\System32\WindowsPowerShell\v1.0\Microso...
CurrentUserAllHosts    NoteProperty string CurrentUserAllHosts=\\OLDSERVER\USERS\lit\My Documents\WindowsPowe...
CurrentUserCurrentHost NoteProperty string CurrentUserCurrentHost=\\OLDSERVER\USERS\lit\My Documents\WindowsP...

PS H:\My Documents> "$Env:USERPROFILE, $Env:HOMEPATH"
C:\Users\lit, \Users\lit

Upvotes: 2

Views: 949

Answers (1)

Eldo.Ob
Eldo.Ob

Reputation: 794

i think the problem is, that Powershell generates that value out of %USERPROFILE%. Technet

There are some SO-Questions no-solutions-here

But maybe you can work around. There is an

PS > $PROFILE.AllUsersCurrentHost
C:\Windows\System32\WindowsPowerShell\v1.0\Microsoft.PowerShellISE_profile.ps1

Maybe you can modify your variables by using $env:USERNAME or loading the profiles on your server.

Example:
write $PROFILE.CurrentUserCurrentHost += ";\\NEWSERVER\{0}\My Documents\WindowsPowerShell\Microsoft.PowerShell_prof.." -f $env:username into the ISE Profile in AllUsersCurrentHost

Greetz Eldo.Ob

Upvotes: 2

Related Questions