Connect-IPPSession connection always failing after a few hour

Aase Nomad 246 Reputation points

I'm trying to retrieve our eDiscovery existing hold using this script ( but the Connect-IPPSession always failing when ever it try to retrieve the second case or after it retrieving a few holds for quick a while.

the script run fine at the beginning but after a couple of minutes I'm getting this error. I think it's because the connection to compliance center failed in the middle of execution.


   Try {  
               $getsessions = Get-PSSession | Select-Object -Property State, Name  
               $isconnected = (@($getsessions) -like '@{State=Opened; Name=ExchangeOnlineInternalSession*').Count -gt 0  
               If ($isconnected -eq "True") {  
                   write-log "Connection already open.  Disconnecting and waiting 30 seconds"  
                   Get-PSSession | Remove-PSSession  
                   Start-Sleep -s 5  
                   Get-PSSession | Remove-PSSession  
                   Start-Sleep -s 10  
                   $pso = New-PSSessionOption -SkipCACheck:$true -SkipCNCheck:$true -SkipRevocationCheck:$true -OperationTimeout 180000 -ProxyAccessType AutoDetect  
                   Connect-IPPSSession -Credential $credential  -ConnectionUri -PSSessionOption $pso  
               else {  
                   $pso = New-PSSessionOption -SkipCACheck:$true -SkipCNCheck:$true -SkipRevocationCheck:$true -OperationTimeout 180000 -ProxyAccessType AutoDetect  
                   Connect-IPPSSession -Credential $credential -ConnectionUri -PSSessionOption $pso  
                   write-log "Connected to Security & Compliance"   

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
11,424 questions
Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,460 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Limitless Technology 39,511 Reputation points

    Hello AaseNomad,

    I would suggest to verify if you are using the script once connected to the Security & Compliance Center PowerShell, as this is only available through that shell.

    Extract: "This cmdlet is available only in Security & Compliance Center PowerShell. For more information, see Security & Compliance Center PowerShell."


    As referenced in the link that you posted, you will need to follow the next connection guide to the Security & Compliance PowerShell in order to execute the eDiscovery script:


    --If the reply is helpful, please Upvote and Accept as answer--

    0 comments No comments