4

I have PowerShell installed on two different Server 2008 R2 systems. On one system, $HOME is prepended to $profile, but on the other nothing is prepended:

Server 1 (PowerShell 2)

PS C:\> echo $HOME
C:\Users\sysnetdom

PS C:\> $profile | format-list -force
CurrentUserAllHosts    : C:\Users\sysnetdom\Documents\WindowsPowerShell\profile.ps1
CurrentUserCurrentHost : C:\Users\sysnetdom\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1

Server 2 (PowerShell 3)

PS C:\> echo $HOME
C:\Users\sysnetdom

PS C:\> $profile | format-list -force
CurrentUserAllHosts    : WindowsPowerShell\profile.ps1
CurrentUserCurrentHost : WindowsPowerShell\Microsoft.PowerShell_profile.ps1

(I snipped the AllUsers paths because those are normal.)

This is a domain account with no assigned home directory. As I understand it, that should cause Windows to assign a default local home. It does, but on Server 2 it doesn't seem to be picked up by PowerShell 3.0.

Is there something I can do about this?

3
  • Does the second server not execute a profile script created in the documents folder? Profile just lists paths you can use. They all should work.
    – Greg Bray
    Jul 19, 2014 at 5:32
  • No it doesn't, that's how I noticed the problem in the first place. Server 1 executes a script in C:\Users\sysnetdom\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1 and server 2 does not.
    – Aaron Hall
    Jul 19, 2014 at 14:25
  • Is the formatting from format-list different on the two different versions of powershell? Try using $profile | Select-Object -ExpandProperty CurrentUserAllHosts and $profile | Select-Object -ExpandProperty CurrentUserCurrentHost. This should give you the raw output. However, my Windows 7 with PS 3.0 looks like your Server 1. Check the contents of the profiles. Maybe Server 2 is loading something that changes formatting.
    – Jeter-work
    Aug 30, 2016 at 1:24

1 Answer 1

0

What I believe you're looking for is the Start in Property of the shortcut you're launching PowerShell from.

If you simply launch the executable, it will start in the path it is located in. C:\WINDOWS\system32\WindowsPowerShell\v1.0, for example. If you launch the executable from a shortcut, it will start wherever the Start in field tells it to, which can be a an absolute path, a relative path, or a path that combines both literal and relative elements.

The PowerShell shortcut on one of my employer's systems, for example:

enter image description here

Personally, I prefer to have it start elsewhere, in my logging folder, to make it easier to find the logs on the command I just ran when I need to, but you can put whatever you want in there... which is what you'd do about this, on "Server 2". Edit that value to what you want it to be.

1
  • Thanks for the advice. I just now checked it, though, and "Start In" is set to %HOMEDRIVE%%HOMEPATH% on both servers, just like your screenshot shows.
    – Aaron Hall
    Jul 18, 2014 at 21:53

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .