Skip to content

Imported modules that were exported seem to be broken #8871

@rfoust

Description

@rfoust

Exporting a module locally (such as Office 365 remote powershell) and then re-importing it results in the cmdlets in that module being broken (on Mac/Linux, haven't tested Windows). The error they return is below. If I just connect to the Office 365 powershell session directly without exporting it, it works fine. So it seems to be something with the re-imported module that breaks it?

Steps to reproduce

$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri "https://outlook.office365.com/powershell-liveid/" -Credential (Get-Credential) -Authentication Basic -AllowRedirection -Name TestTenant
Export-PSSession $Session -OutputModule "path_to_module" -AllowClobber
Import-Module TestTenant -DisableNameChecking -Global

Expected behavior

The imported module should work.

Actual behavior

PS /Users/rfoust> Get-Mailbox
Creating a new session for implicit remoting of "Get-Mailbox" command...
Exception calling "GetSteppablePipeline" with "1" argument(s): "The expression after '&' in
a pipeline element produced an object that was not valid. It must result in a command name, a script
block, or a CommandInfo object."
At /Users/rfoust/.local/share/powershell/Modules/TestTenant/TestTenant.psm1:18294 char:13
+             $steppablePipeline = $scriptCmd.GetSteppablePipeline($myI ...
+             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : NotSpecified: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : CmdletInvocationException

Environment data

Name                           Value
----                           -----
PSVersion                      6.1.2
PSEdition                      Core
GitCommitId                    6.1.2
OS                             Darwin 18.2.0 Darwin Kernel Version 18.2.0: Thu Dec 20 20:46:53 PST 2018; root:xnu-4903.241.1~1/RELEASE_X86_64
Platform                       Unix
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-Questionideally support can be provided via other mechanisms, but sometimes folks do open an issue to get aResolution-No ActivityIssue has had no activity for 6 months or moreWG-Cmdlets-Corecmdlets in the Microsoft.PowerShell.Core module

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions