Forum Discussion

tbresson's avatar
tbresson
Copper Contributor
Aug 13, 2021
Solved

How to re-use authentication with PnP.Powershell

Hello.   I'm trying to make a Powershell script which gathers all of our Microsoft Groups and then go through each of them searching for specific file- & folder content.   With SharePointPnPPower...
  • tbresson's avatar
    Aug 16, 2021
    They way I found to solve it was this - if anyone is looking for the same thing:
    Use the -ReturnConnection parameter to return the current connection to a variable.

    $Connection = Connect-PnPOnline -Url $Url -Interactive -ReturnConnection

    Later when I connect to the different sites I use the ClientId which is returned to the Connection object like this:

    Connect-PnPOnline -Url $Site -Interactive -ClientId $Connection.ClientId

    I still get authentication popups for sites that won't allow me to connect though but I guess this is fine.

Resources