Powershell connection always failing in the middle of the process

Aase Nomad 246 Reputation points
2022-08-04T20:31:00.427+00:00

We use Connect-AzureAD and Connect-IPPSSession in our PowerShell script to do our legal litigation hold stuff. It usually took about at least 3 hour to complete the process and it work fine for the past few weeks.

Some reason the script connection has been failing in the middle of the process for the past few days. I've try resetting my proxy and also try to solve with EMTshooter
https://learn.microsoft.com/en-us/exchange/troubleshoot/administration/connecting-remote-server-failed
but still not work so I would be really appreciated if I can get any help on how to fix this issue.

I even increased the -IdleTimeout but still no luck

           $SessionOpt = New-PSSessionOption -SkipCACheck:$true -SkipCNCheck:$true -IdleTimeout 43200000    
            Connect-IPPSSession -Credential $credential -PSSessionOption $SessionOpt  
       

228239-image.png

Microsoft Exchange Online Management
Microsoft Exchange Online Management
Microsoft Exchange Online: A Microsoft email and calendaring hosted service.Management: The act or process of organizing, handling, directing or controlling something.
4,192 questions
Exchange Server Development
Exchange Server Development
Exchange Server: A family of Microsoft client/server messaging and collaboration software.Development: The process of researching, productizing, and refining new or existing technologies.
511 questions
Exchange Server Management
Exchange Server Management
Exchange Server: A family of Microsoft client/server messaging and collaboration software.Management: The act or process of organizing, handling, directing or controlling something.
7,358 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,381 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Limitless Technology 39,376 Reputation points
    2022-08-08T09:05:39.723+00:00

    Hi there,

    Have you tried Try_Catch_Finally ?

    Use try, catch, and finally blocks to respond to or handle terminating errors in scripts. The Trap statement can also be used to handle terminating errors in scripts.

    about_Try_Catch_Finally

    https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_try_catch_finally?view=powershell-7.2

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

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