Implicit remoting, module import errors out
Posted: Fri Aug 25, 2017 4:27 am
Product, version and build: powershell studio 2012 3.1.35
32 or 64 bit version of product: 64bit
Operating system: Windows 7 home premium
32 or 64 bit OS: 64bit
When I run the below code in Powershell Studio I get an arror while trying to import the modules. When I copy the three commands and take them to the ISE or PowerGui the commands run just fine and the module is imported. I'm totally stuck here.
ERROR: Import-Module : Failure from remote command: Import-Module -Name 'activedirectory': Het doel van een aanroep heeft een uitzondering veroorzaakt.
Globals.ps1 (7): ERROR: At Line: 7 char: 1
ERROR: + Import-Module -PSSession $ADCommands activedirectory
ERROR: + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ERROR: + CategoryInfo : NotSpecified: (:) [Import-Module], InvalidOperationException
ERROR: + FullyQualifiedErrorId : PSRemotingTransportException,Microsoft.PowerShell.Commands.ImportModuleCommand
32 or 64 bit version of product: 64bit
Operating system: Windows 7 home premium
32 or 64 bit OS: 64bit
When I run the below code in Powershell Studio I get an arror while trying to import the modules. When I copy the three commands and take them to the ISE or PowerGui the commands run just fine and the module is imported. I'm totally stuck here.
Code: Select all
$cred = Import-Clixml ${env:localappdata}\creds.xml
$ADCommands = New-PSSession -ComputerName "server01.lab.mydomain.com" -Credential $cred -Authentication "Credssp"
Import-Module -PSSession $ADCommands activedirectory
Globals.ps1 (7): ERROR: At Line: 7 char: 1
ERROR: + Import-Module -PSSession $ADCommands activedirectory
ERROR: + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ERROR: + CategoryInfo : NotSpecified: (:) [Import-Module], InvalidOperationException
ERROR: + FullyQualifiedErrorId : PSRemotingTransportException,Microsoft.PowerShell.Commands.ImportModuleCommand