I have a Powershell GUI program I am writing but having issues with PSSessions for some reason. When the program opens, the function getCredentials fires off.
function getCredentials { $global:rrCredential = Get-Credential -Credential "domain.local\" $global:rrSession = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri http://exchange.domain.local/PowerShell/ -Authentication Kerberos -Credential $rrCredential -ErrorAction SilentlyContinue }
Then later off when we go to create the new user in AD and import the PSSsession with the following but get errors
function createUser { .... lots of other code.... Import-PSSession $rrSession -AllowClobber -DisableNameChecking }
Below is the errors I get
Import-PSSession : Cannot bind parameter 'Session'. Cannot convert the "" value of type "System.String" to type "System.Management.Automation.Runspaces.PSSession". At Z:\End User Support\Scripts\guiToolkit\eusgToolKitbeta.ps1:557 char:24 + Import-PSSession $rrSession -AllowClobber -Di ... + ~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidArgument: (:) [Import-PSSession], ParameterBindingException + FullyQualifiedErrorId : CannotConvertArgumentNoMessage,Microsoft.PowerShell.Commands.ImportPSSessionCommand
This error I don’t believe is a result of the one above but just copying just in case…
Couldn't find the Enterprise Organization container. At Z:\End User Support\Scripts\guiToolkit\eusgToolKitbeta.ps1:1282 char:6 + if (!(Get-Recipient $emailAddress -ResultSize Unlimited -ErrorAct ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [], OrgContainerNotFoundException + FullyQualifiedErrorId : 38824D84