Connect-IPPSession connection always failing after a few hour

Aase Nomad 246 Reputation points
2022-04-12T04:40:12.623+00:00

I'm trying to retrieve our eDiscovery existing hold using this script (https://learn.microsoft.com/en-us/microsoft-365/compliance/create-a-report-on-holds-in-ediscovery-cases?view=o365-worldwide) 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.

192114-12.png

   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 https://nam04.ps.compliance.protection.outlook.com/PowerShell-LiveID -PSSessionOption $pso  
            
               }  
               else {  
                   $pso = New-PSSessionOption -SkipCACheck:$true -SkipCNCheck:$true -SkipRevocationCheck:$true -OperationTimeout 180000 -ProxyAccessType AutoDetect  
                   Connect-IPPSSession -Credential $credential -ConnectionUri https://nam04.ps.compliance.protection.outlook.com/PowerShell-LiveID -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.
10,714 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,389 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Limitless Technology 39,391 Reputation points
    2022-04-19T07:14:09.657+00:00

    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."

    Reference: https://learn.microsoft.com/en-us/powershell/module/exchange/get-caseholdpolicy?view=exchange-ps

    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:

    https://learn.microsoft.com/en-us/powershell/exchange/connect-to-scc-powershell?view=exchange-ps

    ------------------------------------------------------------------------------------------------------------------------

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

    0 comments No comments