none
Inconsistent PowerShell Access to SPOnine

    Question

  • I have installed the SharePoint Online Management Shell.  I can connect to my admin site just fine.  However, when running cmdlets, particularly set-* cmdlets,  my connection seems to be intermittent.  For example, when running a Set-SPOSite to set the SharingCapability for a particular site, I sometimes receive errors similar to the following:

    set-SPOSite : The underlying connection was closed: A connection that was expected to be kept alive was closed by the server.

    OR

    set-SPOSite : The underlying connection was closed: The connection was closed unexpectedly.

    If I rerun the same command, it will eventually go through.  I also administer Offce365 quite a bit through PowerShell and I have never had any connection issues, nor received errors similar to the ones above.

    With the connection so inconsistent, it makes it almost impossible to script any tasks for SharePoint Online through PowerShell, let alone perform simple administration tasks.

    Has anyone come across this before, or have a solution/explanation why this is occurring? 


    • Edited by AndyHJ Monday, February 22, 2016 3:56 PM
    Monday, February 22, 2016 3:55 PM

All replies

  • I've seen something similar before, unpredictable failures in PowerShell scripts that mysteriously go away when you re-run the code. I have three main suspects at this time.

    1. I'm not confident in the quality of the SPO commandlets. They have bugs and the quality of documentation has fallen off a cliff since 2013 days. It could be that there's errors in there that are intermittently kicking in.
    2. We're talking about a cloud service, it's inherrently a more difficult picture than an on-prem one so short term spikes in load or interruptions in communications could cause issues
    3. There is throttling in place for O365, in which case it could be killing your actions to prevent overloading the servers.

    Good luck and if you get an answer from MS please put it up here.

    Saturday, February 27, 2016 10:06 AM