Imported modules that were exported seem to be broken
See original GitHub issueExporting 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
Issue Analytics
- State:
- Created 5 years ago
- Comments:10
Top Results From Across the Web
What does import Module from 'module' import when no ...
In older, pre-ES6 node modules usually no default export is defined. Which means that you cannot import them as an ES6 module. Your...
Read more >@_exported and fixing import visibility - Discussion - ...
The net effect is that some modules end up getting re-exported when you import a library...but it's only those that are needed to...
Read more >Custom blocks cannot be properly exported and imported
This block is broken or missing. You may be missing content or you might need to enable the original module. Go under Custom...
Read more >Understanding Modules and Import and Export Statements ...
In this tutorial, you will learn what a JavaScript module is and how to use import and export to organize your code. Modular...
Read more >CommonJS vs. ES Modules: Modules and Imports in NodeJS
Although at first glance it may seem like module.exports , exports and require are global, actually they are not. CommonJS wraps your code ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@vexx32 Oh wow, doing it that way never occurred to me. Mind blown. 😃 It worked on a quick test! I still need to put that logic in my wrapper function and see how it behaves after the session breaks. But looks promising so far, thanks!
The basic method I’d probably tackle it from is like this:
This might run into the same issue, but… it’s worth a shot nonetheless. 😄