Forum Discussion
My-atix
Jan 05, 2023Copper Contributor
Connect-PnPOnline -Connection parameter???
Hi All, I have a question with regards to the below code... I want add information from a newly created site to a "List" in another site collection. After debugging the following code I can s...
- Jan 08, 2023
My-atix The Connect-PnPOnline cmdlet has a -ReturnConnection parameter which will return the connection object you are looking for.
Change line 5 in your sample above to
$webConnect = Connect-PnPOnline -Url $webUrl -Interactive -ReturnConnection
Good luck!
Please click Mark as Best Response & Like if my post helped you to answer or resolve your issue. This will help others to find the correct solution easily. It also closes the item. If the post was useful in other ways, please consider giving it Like.
SvenSieverding
Jan 05, 2023Bronze Contributor
My-atix
"Connect-PnPOnline" does not return a connection object.
Use "Get-PnPConnection" to get the current connection and store it as a variable
Connect-PnPOnline -Url $webUrl -Interactive
$webConnect = Get-PnPConnection
Connect-PnPOnline -Url $templateSiteUrl -Interactive
$tplSiteConnect = Get-PnPConnection
Get-PnPWeb -Connection $webConnect
Get-PnPWeb -Connection $tplSiteConnect
Best Regards,
Sven