Skip to content

Updating sites PnP Powershell #791

Answered by AndersRask
pratheep-r asked this question in Q&A
Discussion options

You must be logged in to vote

First off, what version are you using, the old depricated SharePointPnPPowerShellOnline or PnP.PowerShell? The old one does not handle throttling, so it is a good idea to set up retry logic if you are being throttled or connections are dropped (429 and 5xx errors)

Secondly, please supply full exception (write out Get-PnPException). We cannot help you if you do not supply the specific exception you are receiving.

Regarding the code, you should use -ReturnConnection and assign a specific connection that you then remember to disconnect inside the loop in a Finally statement after catch:

try {
    $connection = Connect-PnPOnline -ReturnConnection -Url @Site.Url -Credentials $Cred
    ...
Fina…

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@pratheep-r
Comment options

@AndersRask
Comment options

@pratheep-r
Comment options

Answer selected by pratheep-r
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants