Forum Discussion

Dean_Gross's avatar
Dean_Gross
Silver Contributor
Apr 24, 2018

Can no longer run Powershell script

I'm trying to create a script that will copy user accounts from SPO Groups to Office Groups. I'm using an global admin account that has MFA. Yesterday it worked, but today I'm getting the following error: Processing data from remote server outlook.office365.com failed with the following error message: The request for the Windows Remote Shell with ShellId 3AB6B7A1-A423-4D37-B145-1A647B3588C1 failed because the shell was not found on the server. Possible causes are: the specified ShellId is incorrect or the
shell no longer exists on the server. Provide the correct ShellId or create a new shell and retry the operation. 

This is occurring after i get a the login prompt. My script begins with the following code:

$modules = @(Get-ChildItem -Path "$($env:LOCALAPPDATA)\Apps\2.0" -Filter "Microsoft.Exchange.Management.ExoPowershellModule.manifest" -Recurse )
$moduleName = Join-Path $modules[0].Directory.FullName "Microsoft.Exchange.Management.ExoPowershellModule.dll"
Import-Module -FullyQualifiedName $moduleName -Force
$scriptName = Join-Path $modules[0].Directory.FullName "CreateExoPSSession.ps1"
. $scriptName
$null = Connect-EXOPSSession -UserPrincipalName myaccount@tenant.onmicrosoft.com

$exchangeOnlineSession = (Get-PSSession | Where-Object { ($_.ConfigurationName -eq 'Microsoft.Exchange') -and ($_.State -eq 'Opened') })[0]
Import-PSSession $exchangeOnlineSession -AllowClobber -DisableNameChecking
Can anyone tell me what might be causing this problem? 

Resources