Forum Discussion
tbresson
Aug 13, 2021Copper Contributor
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...
- Aug 16, 2021They 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.
tbresson
Aug 16, 2021Copper Contributor
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.
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.