This works perfectly when running the dashboard manually by starting the dashboard.ps1 from PowerShell lSE
But when I run the dashboard as a service, it doesn’t work.
It looks like the session with the Microsoft Exchange server is crated and imported successfully.
But, despite the remote Exchange session being created and imported, $Mailboxes variable is empty for some reason.
I created Universal Dashboard service following this guide.
Absolutely. The user is a member of Remote Management Users group on the target Exchange server.
As I mentioned, It all works well if the Dashboard is ran manually, but when I create the service and run the Dashboard using that service, it starts to fail.
If I remember correctly, the remote management group is not enough here!
The service account, with which the dashboard runs, must be explicitly given the RemotePowerShellEnabled right! This value can also be set only in the Exchange Shell.
The $mailboxes variable is empty.
I already determined that the session gets established and imported correctly.
$Creds work on the Exchange server.
So, I did a little bit of troubleshooting to try to get to the bottom of it and I found that the output of Get-mailbox command is redirected to the console instead to my $Mailboxes variable. That is where the problem is.
Does anybody has any idea why that happens or how to work around it?
I’ve got a lot of “The syntax is not supported by this runspace. This can occur if the runspace is in no-language mode.” errors when manipulating the Exchange cmdlets, so looks like Exchange doesn’t like that method much.
I had to rewrite the code, but I managed to make it work.