Skip to content

Commit

Permalink
Fixing -Connection on Disconnect-PnPOnline throwing an exception (#…
Browse files Browse the repository at this point in the history
…2093)

* Adding dealing with Connection parameter

* Adding dealing with Connection parameter

* Adding changelog entry

* Adding PR reference

* Typo fix
  • Loading branch information
KoenZomers authored Jul 5, 2022
1 parent 6df9114 commit 6c73a50
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
### Removed

### Fixed
- Fixed issue where passing in `-Connection` to `Disconnect-PnPOnline` would throw an exception [#2093](https://github.com/pnp/powershell/pull/2093)

### Contributors
- Koen Zomers [koenzomers]

## [1.11.0]

Expand Down
5 changes: 5 additions & 0 deletions src/Commands/Base/DisconnectOnline.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ public class DisconnectOnline : PSCmdlet

protected override void ProcessRecord()
{
// As parameters are passed in by value, there's no use in doing anything with the connection object here, so we'll simply exit.
#pragma warning disable CS0618
if(Connection != null) return;
#pragma warning restore CS6018

if(PnPConnection.Current == null)
{
throw new InvalidOperationException(Properties.Resources.NoConnectionToDisconnect);
Expand Down

0 comments on commit 6c73a50

Please sign in to comment.