Product: PowerShell Universal
Version: 2.8.2
@adam
I have a bunch of scripts that connect to a remote Exchange server.
With a recent update of PSU to version 2.8.0, those scripts stopped working. Updating to 2.8.2 does not solve it.
$pssession = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri "http://exchange-server-hostname-redacted/PowerShell" -verbose
try
{
$mailboxObject = Invoke-Command -Session $pssession -ScriptBlock {Get-Mailbox "some-mailbox-name" }
}
catch
{
$_
}
Remove-PSSession -Id $pssession.Id
- System.NullReferenceException: Object reference not set to an instance of an object.
at Microsoft.PowerShell.Commands.InvokeCommandCommand.GetHostDebugger()
at Microsoft.PowerShell.Commands.InvokeCommandCommand.BeginProcessing()
at System.Management.Automation.Cmdlet.DoBeginProcessing()
at System.Management.Automation.CommandProcessorBase.DoBegin()
The code causing the null reference exception is the function GetHostDebugger(), for which the source code can be found here:
Could it be that either “InternalHost” or “Runspace” are null, from within the context in PSU?
If I run the same script from a normal Powershell prompt, it runs fine.