Profile Loading Behavior - Not using the global location in %windir%

This topic contains 4 replies, has 3 voices, and was last updated by Profile photo of Karson Van Meeteren Karson Van Meeteren 11 months, 1 week ago.

  • Author
  • #37972
    Profile photo of Karson Van Meeteren
    Karson Van Meeteren

    I have a pretty customized profile.ps1 loaded in my %windir%\system32\windowspowershell\v1.0 path, however when I open a shell, $profile points to a file Microsoft.PowerShell_profile.ps1 profile (that doesn't even exist) from C:\Users\ap.first.last\Documents\WindowsPowerShell\

    I've never seen this behavior before, and refreshing my knowledge on how profiles are handled in powershell has me confused why it's not respecting, and loading, my %windir% profile.

    Can anyone with more insight offer any ideas as to why this is happening? If I move my custom profile.ps1 to that Documents path, even name it the same, it still doesn't load.

  • #37973
    Profile photo of Dave Wyatt
    Dave Wyatt

    The $profile variable is a string that will always have that path. However, it has 4 properties that you can view as well:

    $profile | Format-List -Force

    If you just look at "$profile" without specifying which one, it's equivalent to $profile.CurrentUserCurrentHost

  • #37974
    Profile photo of Dave Wyatt
    Dave Wyatt

    As for why the profile isn't loading at all, that's a different thing. Are you getting any error messages, or does it just silently fail?

  • #37975
    Profile photo of Don Jones
    Don Jones

    And do note that the console and ISE have different host-specific filenames they look for.

  • #37976
    Profile photo of Karson Van Meeteren
    Karson Van Meeteren

    The only error messages I'm getting when loading the console are in reference to snap-ins trying to connect to old server names that are no longer valid, leading me to believe that it is somehow loading a "cached" version.

    SQLSERVER:\> $profile | Format-List -Force
    AllUsersAllHosts       : C:\windows\System32\WindowsPowerShell\v1.0\profile.ps1
    AllUsersCurrentHost    : C:\windows\System32\WindowsPowerShell\v1.0\Microsoft.PowerShell_profile.ps1
    CurrentUserAllHosts    : C:\Users\ap.karson.vanmeetere\Documents\WindowsPowerShell\profile.ps1
    CurrentUserCurrentHost : C:\Users\ap.karson.vanmeetere\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1
    Length                 : 90

    The only file that exists of the four above paths is in the AllUsersAllHosts, but the console is not loading it.

You must be logged in to reply to this topic.