Task
I had an string array of SPO site collection URLs and I needed to execute PowerShell script that fetches comments and likes of app pages across all of these site collections. For getting actual page specific likes and comments, there is PnP PowerShell commands Get-PnPPageLikedByInformation and Get-PnPListItemComment, and you get nice object array including date, and even comment content. No problem there.
However, in my one-time executable script I didn't want to do interactive login for each of those site collections, so I needed a way to somehow persist the credentials and reuse them every time I called Connect-PnPOnline towards each site collection.
Back in the days, all they way in on-prem SharePoint, you could use Get-Credential once and store the credentials in a variable and include that as the parameter in the connection PS command, whatever that was. It, however, hasn't worked in a long time when there are MFA and other requirements towards signing in to online services such as SharePoint Online.
Good thing there is a solution.
Solution
Access tokens to the rescue!
No comments:
Post a Comment