Tagged: cloud computing, office 365
- This topic has 2 replies, 2 voices, and was last updated 9 years, 10 months ago by
Michael Pietroforte.
- AuthorPosts
- Thu, Sep 12 2013 at 1:51 pm #15602
Sometimes, when you test PowerShell scripts with Exchange Online (Office 365), you will get this error message:
New-PSSession: [pod51049psh.outlook.com] Connecting to remote server pod51049psh.outlook.com failed with the following error message:
[Server=DB3PR05CA007,RequestId=53f9abce-bea1-4308-b73b-6b4e5add9871,TimeStamp=8/3/2013 2:04:12 PM] Fail to create a runspace because you have exceeded the maximum number of connections allowed: 3 for the policy party: MaxConcurrency. Please close existing runspace and try again.
This happens whenever you open a remote session to Exchange Online in your script and didn’t close it afterward. Since the maximum number of connections allowed is 3, Office 365 won’t allow you to create a new session.
You can display your open PowerShell sessions (“PSSessions”) with this cmdlet:
Get-PSSession
If you see that you already have three sessions open, you can close them all with this command:
Get-PSSession | Remove-PSSession
To ensure that you don’t again exceed the maximum number of sessions, always close the session at the end of your PowerShell script with:
Remove-PSSession <session>
- Sun, Nov 10 2013 at 7:08 pm #16404
Hey Michael, I have verified this behavior, and the three administrative session limit seems to be “baked into” Exchange Online. See this TechNet link, where they say that you have to “wait for the sessions to expire” if you reach the concurrency limit of 3 sessions: http://technet.microsoft.com/en-us/library/jj984289(v=exchg.150).aspx
So the salient question is, “How long does it take for a remote PowerShell session that was closed on the local box to expire?”
The very bottom of this MS help page (http://help.outlook.com/en-us/140/cc952755.aspx) says:
If you close the Windows PowerShell window without disconnecting from the server-side session, your connection will remain open for 15 minutes.
I guess I would build logic into my PowerShell script to ward against my inadvertently closing the session window. Here are some hacks from Stack Exchange users:
http://stackoverflow.com/questions/9362722/stop-powershell-from-exiting
Hope this helps,
Tim
- Tue, Nov 12 2013 at 1:39 am #16413
Tim, thanks for the tips. Inadvertently closing the window is probably the number reason why the PowerShell session hangs.
- AuthorPosts
- You must be logged in to reply to this topic.