@ToddKlindt and I have been using the module to do some migrations along with Sharegate's PowerShell module. It's fantastic what we've been able to accomplish, if I may be so bold.
We've built a module (.psm1 file) with a bunch of functions we use to drive the migrations. In many of the functions, the Begin block does connections to common locations. Those connections may have been created already by other functions, but we don't want to make that assumption, because we may call the functions independently. We could build some logic into each function, but it would be redundant. Instead, I've put together a Resolve-Connection function that adds new connections to an array and plucks them back out if they already exist.
We're calling some of those those functions many times in foreach loops. It would be great if we could cache connections wherever we make them so we wouldn't incur the overhead every time we enter one of the functions.
Thinking it through, it seems it could work by adding a -Cache switch to Connect-PnPOnline, like so:
The -Cache switch would basically be saying: "Save this connection based on the Url and Credentials. If I ask for it again, send me the cached version - I don't need to reconnect."
If the -Cache switch wasn't there, everything would work as it always has.
This may not prove useful to a lot of people, but in situations where we've got lots of iteration, it could potentially decrease execution time considerably, as well as reducing some of the load on the servers.
Which version of the PnP-PowerShell Cmdlets are you using?
[ ] PnP PowerShell for SharePoint 2013
[ ] PnP PowerShell for SharePoint 2016
[X] PnP PowerShell for SharePoint 2019
[ ] PnP PowerShell for SharePoint Online
How did you install the PnP-PowerShell Cmdlets?
[ ] MSI Installed downloaded from GitHub
[X] Installed through the PowerShell Gallery with Install-Module
Reporting an Issue or Missing Feature
@ToddKlindt and I have been using the module to do some migrations along with Sharegate's PowerShell module. It's fantastic what we've been able to accomplish, if I may be so bold.
We've built a module (.psm1 file) with a bunch of functions we use to drive the migrations. In many of the functions, the Begin block does connections to common locations. Those connections may have been created already by other functions, but we don't want to make that assumption, because we may call the functions independently. We could build some logic into each function, but it would be redundant. Instead, I've put together a
Resolve-Connection
function that adds new connections to an array and plucks them back out if they already exist.We're calling some of those those functions many times in
foreach
loops. It would be great if we could cache connections wherever we make them so we wouldn't incur the overhead every time we enter one of the functions.Thinking it through, it seems it could work by adding a
-Cache
switch toConnect-PnPOnline
, like so:The
-Cache
switch would basically be saying: "Save this connection based on the Url and Credentials. If I ask for it again, send me the cached version - I don't need to reconnect."If the
-Cache
switch wasn't there, everything would work as it always has.This may not prove useful to a lot of people, but in situations where we've got lots of iteration, it could potentially decrease execution time considerably, as well as reducing some of the load on the servers.
Which version of the PnP-PowerShell Cmdlets are you using?
How did you install the PnP-PowerShell Cmdlets?