PnP Session mehrfach verwenden

Kurztipp: Mit PnP könnt ihr sehr einfach eine Verbindung mehrfach verwenden, anstatt für einzelne Abfragen immer zuerst die Site neu zu verbinden.

Connect-PnPOnline stellt den Parameter ReturnConnection zur Verfügung. So könnt ihr die Verbindung als Variable speichern,…

$PnPConnection = Connect-PnPOnline -Url [SiteUrl] -Credentials [Credentials] -ReturnConnection

oder falls ihr bereits mit einer Site verbunden seid als Alternative Get-PnPConnection.

$PnPConnection = Get-PnPConnection

Die Verbindung könnt ihr überall dort einsetzen wo es möglich ist über den Parameter Connection eine gespeicherte Verbindung anzugeben; Beispiel Get-PnPListItem.

Get-PnPListItem -List "DemoList" -Id 50 -Connection $PnPConnection
Share
Avatar photo

Tobias Asböck

Tobias is a Senior System Engineer with more than 10 years of professional experience with Microsoft 365 products such as SharePoint Online, SharePoint Premium, OneDrive for Business, Teams Collaboration, Entra ID, Information Protection, Universal Print, and Microsoft 365 Licensing. He also has 15+ years of experience planning, administering, and operating SharePoint Server environments. Tobias is a PowerShell Scripter with certifications for Microsoft 365 products. In his spare time, Tobias is busy with updates in the Microsoft 365 world or on the road with his road bike and other sports activities. If you have additional questions, please contact me via LinkedIn or [email protected].

Leave a Reply

Your email address will not be published. Required fields are marked *