none
Loading modules when using enter-pssession

    Pertanyaan

  • Hello

    I see some thing that appears unusual to me.

    Server1 is running PowerShell v2
    Client1 is running PowerShell v2

    If I am logged directly to Server1 and do

    $Host
    $PSVersionTable

    I get the result I would expect e.g. version 2 and PSVersion2. I can also load Modules in the normal way directly from Server1 e.g. Import-Module ...

    From Client1 (or any other client) if I Enter-PSSession Server1 then

    $Host
    $PSVersionTable

    I get the following verion 1 and PSVersion 2

    So basically even though the PSVersion is 2 the Host (e.g. PS-Session Host) is version 1, and therefore I cannot load Modules as I get the following error if I try

    Import-Module : The current PowerShell host is: 'ServerRemoteHost' (version 1.0.0.0). The module

    'C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules\pspki\pspki.psd1' requires a minimum PowerShell ho
    st version of '2.0' to execute.

    So it occurs to me the "Host" execution environment you get with PS-Session is a cut down version e.g. version 1

    Is this normal? is there a work around for it?

    Thanks All

    AAnotherUser__



    AAnotherUser__

    • Dipindahkan oleh Bill_Stewart Rabu, 16 Juli 2014 15.22 Abandoned
    Kamis, 05 Juni 2014 09.01

Semua Balasan

  • What is a client system? YOu say "client1" which is some PC that is not a "server class" PC is running PowerShell V2.  What does that mean.

    At any V2 system prompt this is what V2 displays:

    PS C:\scripts> $host
    
    
    Name             : ConsoleHost
    Version          : 2.0
    InstanceId       : 5bfce22c-8b10-4c67-8dd7-435ff1c351a7
    UI               : System.Management.Automation.Internal.Host.InternalHostUserInterface
    CurrentCulture   : en-US
    CurrentUICulture : en-US
    PrivateData      : Microsoft.PowerShell.ConsoleHost+ConsoleColorProxy
    IsRunspacePushed : False
    Runspace         : System.Management.Automation.Runspaces.LocalRunspace
    
    
    
    PS C:\scripts> $psversiontable
    
    Name                           Value
    ----                           -----
    CLRVersion                     2.0.50727.3655
    BuildVersion                   6.0.6002.18111
    PSVersion                      2.0
    WSManStackVersion              2.0
    PSCompatibleVersions           {1.0, 2.0}
    SerializationVersion           1.1.0.1
    PSRemotingProtocolVersion      2.1
    
    

    Host will report Version 2.0  if it doesn;t you are not running V2 you are running V1.


    ¯\_(ツ)_/¯

    Kamis, 05 Juni 2014 09.48
  • Hello Jrv

    Thank you for replying,

    Client1 (I have tried both Windows 7 Running PowerShell v4, and Windows 2008 R2 running PowerShell v2)

    SO basically, if I am "directly" on the console of Server1 (Windows 2003 R2 running PoweShell v2)

    it tells me I have PowerShell v2 (e.g. both $Host and $PSVersionTable) and I can load Modules OK.

    From a Client if I Enter-PSSession -Computer Server1

    $host
    tell me I am using PowerShell v1.0.0.0 and therefore cannot import-module (see error above). Although $PSVersionTable still tells me it is PowerShell v2

    therefore I can only assume the "Host Environment" provides by PSSession is dubed down.

    Thanks again

    AAnotherUser__


    AAnotherUser__

    Kamis, 05 Juni 2014 11.15
  • You are saying you get that when typing "$host"

    That doesn't make any sense.


    ¯\_(ツ)_/¯

    Kamis, 05 Juni 2014 11.31
  • If I remote from a V2 client to a V4 server thisis what I get

    [w8test]: PS > $host
    
    
    Name             : ServerRemoteHost
    Version          : 1.0.0.0
    InstanceId       : fe40d48a-6cd1-4491-b571-b086d8e6ab6f
    UI               : System.Management.Automation.Internal.Host.InternalHostUserInterface
    CurrentCulture   : en-US
    CurrentUICulture : en-US
    PrivateData      :
    IsRunspacePushed :
    Runspace         :
    

    Note that it is the SecureRemoteHost that is Version 1 and NOT PowerShell.


    ¯\_(ツ)_/¯

    Kamis, 05 Juni 2014 11.35
  • Hello Jrv

    Yes that's what I was thinking must be happending, e.g. the 'host' like ISE is a 'host' etc.

    what a pain in the but!

    I cannot load a module on the remote Server when using enter-pssession (I will try invoke command), I wounder why the PowerShell team engineered it like this? is there a work around to the import-module issue when using enter-pssession

    Thank you

    AAnotherUser__


    AAnotherUser__

    Kamis, 05 Juni 2014 13.39
  • I have no idea what you are talking about.  There is no reason why you cannot load a module.  We do it all of the time.

    Something you are doing is missing or being misreported.

    If you cannot run $host then you have an issue with your setup or profile. $host is a predefined variable. If it fails then you have done something to destroy this built in variable.

    Use "New-PsSessionOption with -NoMachineProfile"

    This will prevent loading of the remote profile.


    ¯\_(ツ)_/¯

    Kamis, 05 Juni 2014 14.30
  • Thanks Jrv

    I can use the $host option no problem

    its just when I access Server1 from a client (any client another server or workstation) $host shows as 1.0.0.0 e.g. PS v1. Therefore when I type import-module it throws the error above e.g. you need to be running PS v2 (which Server1 is) but PSSession host appears to be restricting me to PS v1 actions only (e.g. snapins and not modules).

    I should not PS v1 was installed on Server1 previously then upgraded to PS v2

    So my problem is I cannot use Enter-PSSession To Server1 then load any modules

    Thank you

    AAnotherUser__


    AAnotherUser__

    Kamis, 05 Juni 2014 19.03
  • Last time.  $host does NOT shoe that. Her eis what it shows,

    Name             : ServerRemoteHost
    Version          : 1.0.0.0

    It is the remote host component that is version 1.0.0.0.  The PowerShell local host is the version of POwerSHell installed.  They are two different host executable files.

    That is the correct version of the remote host.  That is the only version of the remote host.  It has nothing to do wioth loading modules.  Modules load just fine.


    ¯\_(ツ)_/¯

    Kamis, 05 Juni 2014 20.36
  • JRV, I'm not sure why you're unable to understand what's being asked. I'll try to use small words:

    enter-pssession -computername whateverhost

    I'm connected and $host returns "Name: ServerRemoteHost, Version: 1.0.0.0, etc". So I'm unable to run commands like Get-LocalGroupMember. 

    If I run powershell from the console on whateverhost then $host returns "Name: ConsoleHost, Version: 4.0, etc".

    None of the commands I'm trying to run via enter-pssession will work because "whatever it is" is running v1 instead of v4. HOW DOES ONE GET AROUND THAT.


    Kamis, 27 September 2018 23.19
  • JRV, I'm not sure why you're unable to understand what's being asked. I'll try to use small words:

    enter-pssession -computername whateverhost

    I'm connected and $host returns "Name: ServerRemoteHost, Version: 1.0.0.0, etc". So I'm unable to run commands like Get-LocalGroupMember. 

    If I run powershell from the console on whateverhost then $host returns "Name: ConsoleHost, Version: 4.0, etc".

    None of the commands I'm trying to run via enter-pssession will work because "whatever it is" is running v1 instead of v4. HOW DOES ONE GET AROUND THAT.


    Please do not post in this forum as it is clearly marked as "Off Topic (Do not post here)".


    \_(ツ)_/


    • Diedit oleh jrv Kamis, 27 September 2018 23.28
    Kamis, 27 September 2018 23.28
  • Then remove useless "help" pages from Google results my man.

    For the record, upgrading to PS 5.1 on the servers fixed this issue *THAT CAN BE MARKED AS SOLVED*.

    Kamis, 27 September 2018 23.45
  • Then remove useless "help" pages from Google results my man.

    For the record, upgrading to PS 5.1 on the servers fixed this issue *THAT CAN BE MARKED AS SOLVED*.

    Why are you so belligerent. This thread I 4 years old and was abandoned which is why the moderators moved it to the dead letter bin.

    Your solution has nothing to do with what was happening 4 years ago.  Yes.  Upgrading all nodes to the same newer version of WMF will cause them all to have the 3.0 engine.  This should be obvious.

    Perhaps you should be less combative and use the energy to learn more about technology.

     


    \_(ツ)_/

    Jumat, 28 September 2018 00.41