Why does remote PS profile not run? RRS feed

  • Question

  • Should be relatively simple:

    Created PS user profile on destination host

    Created AllUsersCurrentHost profile on destination host

    Created AllUsersAllHosts profile on destination host

    All containing:

    $PSSessionOption = New-PSSessionOption -IncludePortinSPN

    When I do a remote desktop session to the destination host, enter PowerShell and enter $PSSessionOption I can see that the IncludePortinSPN option is set to True.

    If I go back to the source host, enter PowerShell, enter in command 'Enter-PSSession {destination host}' and then do a $PSSessionOption then IncludePortinSPN is set to false. Which indicates that neither of the remote PS profiles are being run when I do the Enter-PSSession. Why would that be?

    PS! Please note that we do not have the luxury of specifying any profile as the PS session is created via TFS and not interactively. So we need the remote profile to be loaded automatically for any PS session.

    Any tips are appreciated.

    Regards, Stig

    Regards, Stig

    Friday, September 21, 2018 7:55 AM

All replies

  • Remote sessions do not load a profile.


    Friday, September 21, 2018 8:01 AM
  • Thanks for the answer.

    This Technet article clearly states that the remote profile should be loaded. Are we saying that MS has documented this incorrectly (or maybe it is outdated)?


    And then also in this article as well https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/enter-pssession?view=powershell-6 

    Seems strange that they should consistently document this incorrectly.

    Regards, Stig

    Friday, September 21, 2018 8:34 AM
  • Then check to be sure your profile is in the correct place.

    If the profile is on a remote share it may not be executed.


    Friday, September 21, 2018 8:56 AM
  • They are definitely in the right place on the destination host. PS user profile created by proper PS command. Proof is that it runs when running PowerShell locally on the destination host.

    AllUsersCurrentHost and AllUsersAllHosts profiles are in C:\Windows\System32\WindowsPowerShell\v1.0 and using the correct names as indicated by PS commands:



    I have also checked the ExecutionPolicy where this is set for LocalMachine as RemoteSigned. So it should not require anything more to run the scripts as they are created locally.

    Regards, Stig

    Friday, September 21, 2018 9:01 AM