File tree Expand file tree Collapse file tree 1 file changed +12
-2
lines changed
Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -15,11 +15,21 @@ public class DisconnectOnline : BasePSCmdlet
1515 [ Parameter ( Mandatory = false ) ]
1616 public SwitchParameter ClearPersistedLogin ;
1717
18+ private static readonly string [ ] sourceArray = [ "stop" , "ignore" , "silentlycontinue" ] ;
1819 protected override void ProcessRecord ( )
1920 {
21+
2022 if ( PnPConnection . Current == null )
2123 {
22- throw new InvalidOperationException ( Properties . Resources . NoConnectionToDisconnect ) ;
24+ // If the ErrorAction is not set to Stop, Ignore or SilentlyContinue throw an exception, otherwise just continue
25+ if ( ! sourceArray . Contains ( ErrorActionSetting . ToLowerInvariant ( ) ) )
26+ {
27+ throw new InvalidOperationException ( Properties . Resources . NoConnectionToDisconnect ) ;
28+ }
29+ else
30+ {
31+ return ;
32+ }
2333 }
2434
2535 Environment . SetEnvironmentVariable ( "PNPPSHOST" , string . Empty ) ;
@@ -34,7 +44,7 @@ protected override void ProcessRecord()
3444 PnPConnection . Current . Certificate = null ;
3545 }
3646
37- if ( ClearPersistedLogin )
47+ if ( ClearPersistedLogin )
3848 {
3949 PnPConnection . ClearCache ( PnPConnection . Current ) ;
4050 }
You can’t perform that action at this time.
0 commit comments