none
How do I get rid of the "Can't generate Export-Module for the current session using Import-PSSession" message in EMS? RRS feed

  • Question

  • When I start EMS on my Server 2012 machine running Exchange 2010, I always get this:

    VERBOSE: Connecting to Exchange-TNG.simcoe.local

    Microsoft.PowerShell.Commands.ExportPSSessionCommand, Microsoft.PowerShell.Commands.Utility, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 : Unable to find type [Microsoft.PowerShell.Commands.ExportPSSessionCommand, Microsoft.PowerShell.Commands.Utility, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]: make sure that the assembly containing this type is loaded. At C:\Users\administrator.SIMCOE\AppData\Roaming\Microsoft\Exchange\RemotePowerShell\exchange-tng.simcoe.local\exchange-tng.simcoe.local.psm1:16 char:217+ $script:__psImplicitRemoting_versionOfScriptGenerator = Microsoft.PowerShell.Commands.ExportPSSessionCommand, Microsoft.PowerShell.Commands.Utility, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35] <<<< ::VersionOfScriptGenerator   + CategoryInfo          : InvalidOperation: (Microsoft.Power...1bf3856ad364e35:String) [], ParentContainsErrorReco   rdException   + FullyQualifiedErrorId : TypeNotFound

    WARNING: Can't generate Export-Module for the current session using Import-PSSession.

    VERBOSE: Connected to Exchange-TNG.simcoe.local.

    When the last line appears, two popups appear in succession saying “creating implicit remoting module.”  The prompt then returns, and I an issue Exchange-specific commands like get-exchangeserver.

    I have been troubleshooting this for a week.  The warning is a common one, but none of what’s worked for other users works for me.  I’ve tried intranet exclusions, permissions … everything.  One user got it to work by renaming web.conifg in the intetpub/wwwroot directory, but mine doesn’t have that file.  How can I load the commands that powershell is looking for?   Is there a profile setting I should be looking for?

    • Moved by Bill_Stewart Friday, February 24, 2017 6:25 PM Move to more appropriate forum
    Friday, February 24, 2017 5:10 PM

Answers

  • I had the same issue.. Digging through found out that it is due to July patch pushed by Microsoft. https://support.microsoft.com/en-us/help/4025333/windows-8-update-kb4025333. Look at the known issues section and you will be able to see exact same error pointed out. 

    Solution is to install KB3000850

    Thanks,


    Thursday, August 3, 2017 4:39 PM

All replies

  • What version of PowerShell.  EX2010 only supports PS2 without the latest updates.


    \_(ツ)_/


    • Edited by jrv Friday, February 24, 2017 5:37 PM
    Friday, February 24, 2017 5:37 PM
  • Hmm ... my Powershell version is 4.0, but my EMS version is 2.0.  Are there updates that can help me?

    Friday, February 24, 2017 7:53 PM
  • Run PowerShell 2 and load the shell from there.  You will also need to install the Exchange updates i you haven't and I suspect you haven't from the errors.

    This is from the installation notes:

    Servers that are running the following applications can now run WMF 4.0. The versions listed are the minimum releases required to run WMF 4.0.


    \_(ツ)_/

    Friday, February 24, 2017 8:47 PM
  • I have Exchange 2010 SP3 with rollup 15 as of last December.  You can have two versions of Powershell installed simultaneously?

    Friday, February 24, 2017 9:22 PM
  • Powershell v2 is always available if the feature is enabled

    powershell -version 2

    will run version 2


    \_(ツ)_/

    Friday, February 24, 2017 9:25 PM
  • Thanks, but EMS must already be launching with this parameter ...  how else could it be reporting version 2?

    Friday, February 24, 2017 10:30 PM
  • Then you have a conflict.  You will have to figure out what is damaged or missing.

    I have also seen similar things when there is an old module in the module path.

    You are in the Exchange forum now so maybe someone else here has seen this and knows what might cause it.

    You could start by using the netfix utility to check the net installation. 

    It would also be helpful if you posted the error more clearly.  It looks like you have three errors al clumped together.


    \_(ツ)_/

    Friday, February 24, 2017 11:18 PM
  • What version of PowerShell.  EX2010 only supports PS2 without the latest updates.


    \_(ツ)_/


    Correct that Exchange 2010 only supports using V2, but if this is installed on a newer OS, then additional are available

    https://technet.microsoft.com/en-us/library/ff728623%28v=exchg.150%29.aspx?f=255&MSPPError=-2147217396

    Windows Management Framework 3.0 and Windows Management Framework 4.0 can be used to perform operating system-related management tasks on a computer that's running Exchange 2010 SP3 RU5 or later. However, Exchange 2010 cmdlets and Exchange 2010 scripts require Windows PowerShell 2.0. Using Exchange 2010 cmdlets and scripts with Windows Management Framework 3.0 or Windows Management Framework 4.0 isn't supported.


    Cheers,

    Rhoderick

    Microsoft Senior Exchange PFE

    Blog: http://blogs.technet.com/rmilne  Twitter:   LinkedIn:   Facebook:   XING:

    Note: Posts are provided “AS IS” without warranty of any kind, either expressed or implied, including but not limited to the implied warranties of merchantability and/or fitness for a particular purpose.

    Saturday, February 25, 2017 3:38 PM
  • First things first - prove that the box and Exchange is working.

    Do a manual Remote PowerShell connection.

    Specifically, load up standard Windows PowerShell (NOT EMS) using the version switch at the bottom of this article

    https://blogs.technet.microsoft.com/rmilne/2016/08/25/unable-connect-exchange-remote-powershell-using-windows-10-anniversary-update/

    then create a manual Remote Exchange PowerShell session using the steps in this post:

    https://blogs.technet.microsoft.com/rmilne/2011/12/20/how-to-maximize-exchange-administrator-productivity-with-powershellpart-2/


    Cheers,

    Rhoderick

    Microsoft Senior Exchange PFE

    Blog: http://blogs.technet.com/rmilne  Twitter:   LinkedIn:   Facebook:   XING:

    Note: Posts are provided “AS IS” without warranty of any kind, either expressed or implied, including but not limited to the implied warranties of merchantability and/or fitness for a particular purpose.

    Saturday, February 25, 2017 3:58 PM
  • What version of PowerShell.  EX2010 only supports PS2 without the latest updates.


    \_(ツ)_/


    Correct that Exchange 2010 only supports using V2, but if this is installed on a newer OS, then additional are available

    https://technet.microsoft.com/en-us/library/ff728623%28v=exchg.150%29.aspx?f=255&MSPPError=-2147217396

    Windows Management Framework 3.0 and Windows Management Framework 4.0 can be used to perform operating system-related management tasks on a computer that's running Exchange 2010 SP3 RU5 or later. However, Exchange 2010 cmdlets and Exchange 2010 scripts require Windows PowerShell 2.0. Using Exchange 2010 cmdlets and scripts with Windows Management Framework 3.0 or Windows Management Framework 4.0 isn't supported.


    Cheers,

    Rhoderick

    Microsoft Senior Exchange PFE

    Blog: http://blogs.technet.com/rmilne  Twitter:   LinkedIn:   Facebook:   XING:

    Note: Posts are provided “AS IS” without warranty of any kind, either expressed or implied, including but not limited to the implied warranties of merchantability and/or fitness for a particular purpose.

    This is why I found it easier to use remote exchange from a workstation because you can use remote exchange with PS3 and higher.

    I also leaned one thing the hard way.  It we install PS 3 or pater before adding the updates to Exchange 2010 then EMS will stop working and likely fail even after installing the updates.  Only re-installing Exchange can fix this unless someone has figured out what gets clobbered and how to repair it.


    \_(ツ)_/

    Saturday, February 25, 2017 6:21 PM
  • I eliminated a startup script I found in the /documents/windowspowershell directory, and after one try where it launched two sub processes, it now loads normally, getting you the connection and prompt quickly.
    Saturday, February 25, 2017 9:17 PM
  • Startup script?  PowerShell does not have startup scripts.  Are you asking about profiles?  If you have a profile that already loads an Exchange module then the second attempt will fail.

    Of course none of this has anything to do with remote sessions or third party tools.


    \_(ツ)_/

    Saturday, February 25, 2017 9:56 PM
  • @ArtSnob, any update about this issue?
    Please cleanup the folder under %userprofile%\AppData\Roaming\Microsoft\Exchange\RemotePowerShell\, then sign out and sign in for testing.

    If this issue remain exist, use remote PowerShell to connect to Exchange server:
    $UserCredential = Get-Credential
    $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri http://<FQDN of Exchange 2013 Client Access server>/PowerShell/ -Authentication Kerberos -Credential $UserCredential
    Import-PSSession $Session
    More details, refer to: Connect to Exchange using remote Shell.

    Best Regards,

    Allen Wang


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    • Proposed as answer by Allen_WangJF Friday, March 3, 2017 3:22 PM
    Monday, February 27, 2017 8:51 AM
  • Same error on W2012R2

    Exchange DAG 2 node.

    ProductVersion
    --------------
    15.00.1178.009

    Test confirms that Exchange commands do not loads in EMS

    VERBOSE: Connecting to myexchangeB.domain.com
    WARNING: Can't generate Export-Module for the current session using Import-PSSession.
    VERBOSE: Connected to myexchangeB.domain.com.

    [PS] C:\Windows\system32>get-module ModuleType Version Name ExportedCommands ---------- ------- ---- ---------------- Manifest 3.1.0.0 Microsoft.PowerShell.Management {Add-Computer, Add-Content, Checkpoint-Computer, Clear-Con... Manifest 3.0.0.0 Microsoft.PowerShell.Security {ConvertFrom-SecureString, ConvertTo-SecureString, Get-Acl... Manifest 3.1.0.0 Microsoft.PowerShell.Utility {Add-Member, Add-Type, Clear-Variable, Compare-Object, Con...

    @Allen_WangJF Suggestion gives an error

    PS C:\Windows\system32> Import-PSSession $Session
    Import-PSSession : Method not found: 'System.String System.Management.Automation.CommandMetadata.EscapeBlockComment(Sys
    tem.String)'.
    At line:1 char:1
    + Import-PSSession $Session
    + ~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : NotSpecified: (:) [Import-PSSession], MissingMethodException
        + FullyQualifiedErrorId : System.MissingMethodException,Microsoft.PowerShell.Commands.ImportPSSessionCommand
    

    But it works if you change the code to this:

    $UserCredential = Get-Credential
    $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri ('http://'+$env:COMPUTERNAME+'.'+$env:USERDNSDOMAIN+'/PowerShell/') -Authentication Kerberos -Credential $UserCredential
    Enter-PSSession $Session


    It is still not a solution, cause EMS continue to show

    VERBOSE: Connecting to myexchangeB.domain.com
    WARNING: Can't generate Export-Module for the current session using Import-PSSession.
    VERBOSE: Connected to myexchangeB.domain.com.

    And no one Exchange command can run.

    Server Restart doesn't help.

    Workaround solution

    1. Delete all under %userprofile%\AppData\Roaming\Microsoft\Exchange\RemotePowerShell\
    2. Log off/Log on
    3. in Elevated cmd: iisreset
    4. Wait 1 min.
    5. In Elevated CommandPromt type: 
    C:\Windows\system32>powershell -version 2
    Windows PowerShell
    Copyright (C) 2009 Microsoft Corporation. All rights reserved.
    
    PS C:\Windows\system32>
     

      6. After that in the same window run

    . $env:ExchangeInstallPath\bin\RemoteExchange.ps1
    Connect-ExchangeServer -Auto

     7. You will get a lot of errors and you'll be asked once to type the server FQDN, Type it.
    Easy find your server FQDN in PS:
    $env:COMPUTERNAME+'.'+$env:USERDNSDOMAIN
    or
    (Get-WmiObject win32_computersystem).DNSHostName+"."+(Get-WmiObject win32_computersystem).Domain

    8. In Elevated Windows Powershell

    . $env:ExchangeInstallPath\bin\RemoteExchange.ps1
    Connect-ExchangeServer -Auto -ClearCache

    And now you can start EMS, that should work.

    I do not know why, but it helped me twice.

    • Proposed as answer by uzit Friday, July 28, 2017 11:24 AM
    Friday, July 28, 2017 11:17 AM
  • @uzit Thanks for your solution, worked perfectly fine ....... at the beginning

    Now the error reoccurred and I can’t solve it with that.
    I’m getting the exact same error as you (only the warning at the opening, and the "Method not found" if I read the $error variable)

    If i try the manual method with Import-PSSession I’m getting the same "Method not Found" error as the EMS, and with Enter-PSSession I can only use really basic commands and getting a "command not found" error for all the others.

    Any idea how to solve this?

     

    Thursday, August 3, 2017 9:54 AM
  • I had the same issue.. Digging through found out that it is due to July patch pushed by Microsoft. https://support.microsoft.com/en-us/help/4025333/windows-8-update-kb4025333. Look at the known issues section and you will be able to see exact same error pointed out. 

    Solution is to install KB3000850

    Thanks,


    Thursday, August 3, 2017 4:39 PM
  • Thanks nani023, installed the update and now it works perfectly fine again!
    Monday, August 7, 2017 11:31 AM
  • Thank you nani023! i've been looking for the fix for weeks!
    Monday, August 7, 2017 9:15 PM
  • I can confirm what you have found. KB4025333 is causing this and installation of KB3000850 resolves.

    Thank you very much
    Daniel

    Wednesday, August 9, 2017 5:41 AM
  • Nice found !

    It work also for me !

    Thanks

    Thursday, August 24, 2017 3:01 PM