invokemethodonnull powershell try catch

C++
PS C:\Scripts\PowerShell> C:\Scripts\PowerShell\Add SA3Cloud\Add-SA3Cloud.ps1
Office is: \\sa3cloud\LOPD
Location is LOPD
WARNING: \\sa3cloud\LOPD
WARNING: System.Management.Automation.RuntimeException: You cannot call a method on a null-valued expression.
   at System.Management.Automation.ExceptionHandlingOps.CheckActionPreference(FunctionContext funcContext, Exception exception)
   at System.Management.Automation.Interpreter.ActionCallInstruction`2.Run(InterpretedFrame frame)
   at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
   at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)

Source

Also in C++: