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

Welcome Forums General PowerShell Q&A Profile Loading Behavior - Not using the global location in %windir%

This topic contains 4 replies, has 3 voices, and was last updated by

2 years, 7 months ago.

  • Author
  • #37972

    Points: 0
    Rank: Member

    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

    Points: 0
    Rank: Member

    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

    Points: 0
    Rank: Member

    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

    Points: 1,639
    Helping HandTeam Member
    Rank: Community Hero

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

  • #37976

    Points: 0
    Rank: Member

    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.

The topic ‘Profile Loading Behavior - Not using the global location in %windir%’ is closed to new replies.