Reporting an Issue or Missing Feature
ISSUE
Breaking change from 1.10.0 to 1.12.0 that including -ReturnConnection on Connect-PnPOnline and not using -Connection parameter on cmdlets will result in InvalidOperationException
Expected behavior
In earlier versions you could specify -ReturnConnection when connecting to SharePoint Online, and not use it, as the connection was "given" implicitly as latest connection.
# example 1: with -ReturnConnection and not using -Connection
Connect-PnPOnline -Url "https://mytenant-admin.sharepoint.com/" -Interactive -ReturnConnection
Get-PnPList
Disconnect-PnPOnline
# Would list all lists on site collection
# example 2: omitting -ReturnConnection would also work
Connect-PnPOnline -Url "https://mytenant-admin.sharepoint.com/" -Interactive
Get-PnPList
Disconnect-PnPOnline
# Would list all lists on site collection
# example 3: with -ReturnConnection using -Connection
$connection = Connect-PnPOnline -Url "https://mytenant-admin.sharepoint.com/" -Interactive -ReturnConnection
Get-PnPList -Connection $connection
Disconnect-PnPOnline
# Would list all lists on site collection
Actual behavior
Example 1 will no longer work in 1.12.0 introducing a breaking change in a minor version change.
This may very well be pr design as of the connection rework also of disconnecting connections, but since it is a breaking change, this breaks code that would work in earlier versions it would be nice with backward compatibility handling, like a warning or error if you use -ReturnConnection
# including -ReturnConnection and not using it will throw error
Connect-PnPOnline -Url "https://mytenant-admin.sharepoint.com/" -Interactive -ValidateConnection -ReturnConnection
Get-PnPList
# In 1.12.0 this will now return an InvalidOperationException:
Get-PnPList: The current connection holds no SharePoint context. Please use one of the Connect-PnPOnline commands which uses the -Url argument to connect.
Steps to reproduce behavior
run the code below in 1.10.0 and 1.12.0 and notice that ex 1 will throw error
# example 1: with -ReturnConnection and not using -Connection
Connect-PnPOnline -Url "https://mytenant-admin.sharepoint.com/" -Interactive -ReturnConnection
Get-PnPList
Disconnect-PnPOnline
# Would list all lists on site collection but only in v1.10.0
# example 2: omitting -ReturnConnection would also work
Connect-PnPOnline -Url "https://mytenant-admin.sharepoint.com/" -Interactive
Get-PnPList
Disconnect-PnPOnline
# Would list all lists on site collection
# example 3: with -ReturnConnection using -Connection
$connection = Connect-PnPOnline -Url "https://mytenant-admin.sharepoint.com/" -Interactive -ReturnConnection
Get-PnPList -Connection $connection
Disconnect-PnPOnline
# Would list all lists on site collection
What is the version of the Cmdlet module you are running?
1.10.0 and 1.120.
Which operating system/environment are you running PnP PowerShell on?
Reporting an Issue or Missing Feature
ISSUE
Breaking change from 1.10.0 to 1.12.0 that including
-ReturnConnectiononConnect-PnPOnlineand not using-Connectionparameter on cmdlets will result inInvalidOperationExceptionExpected behavior
In earlier versions you could specify -ReturnConnection when connecting to SharePoint Online, and not use it, as the connection was "given" implicitly as latest connection.
Actual behavior
Example 1 will no longer work in 1.12.0 introducing a breaking change in a minor version change.
This may very well be pr design as of the connection rework also of disconnecting connections, but since it is a breaking change, this breaks code that would work in earlier versions it would be nice with backward compatibility handling, like a warning or error if you use -ReturnConnection
Steps to reproduce behavior
run the code below in 1.10.0 and 1.12.0 and notice that ex 1 will throw error
What is the version of the Cmdlet module you are running?
1.10.0 and 1.120.
Which operating system/environment are you running PnP PowerShell on?