Disconnect PnP Online with connections parameter #3239
Answered
by
AndersRask
pratheep-r
asked this question in
Q&A
Replies: 2 comments 1 reply
-
As the error say, connection parameter does not exist.
It was removed several versions ago. I general you should not disconnect
connections, just make new ones with new sites.
man. 3. jul. 2023 18.11 skrev Pra-R ***@***.***>:
… As a part of the script, within "foreach" loop I am trying to disconnect
in "finally" block. However getting the attached error
Code in nutshell
$Cred = Get-Credential try { $Connection = Connect-PnPOnline
-ReturnConnection -url "
https://ukaeauk.sharepoint.com/sites/EmergencyResponse" -Credentials
$Cred # Do something } catch { write-host -f Red "tError:"
$_.Exception.Message
}
finally {
If ($null -ne $Connection) {
Disconnect-PnPOnline -Connection $Connection
}
}`
Please advise/help.
[image: 2023-07-03 17_01_38-● Test ps1 - DisconnectPnP]
<https://user-images.githubusercontent.com/56027088/250609414-d44e05eb-5636-413a-bf1f-04f4b653007d.png>
—
Reply to this email directly, view it on GitHub
<#3239>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAMTDTWRVIPJAK3ZLGYPHI3XOLVLFANCNFSM6AAAAAAZ4VALOA>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
pratheep-r
-
No, it's actually recommended not to (read on the description for the
cmdlet) since it's the credential that is cached
man. 3. jul. 2023 18.27 skrev Pra-R ***@***.***>:
… Ah okay, thanks. Are we not running the risk of leaving it connected?
—
Reply to this email directly, view it on GitHub
<#3239 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAMTDTWBXPXKZOISIDVEDWTXOLXIFANCNFSM6AAAAAAZ4VALOA>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
As a part of the script, within "foreach" loop I am trying to disconnect in "finally" block. However getting the attached error
Code in nutshell
$Cred = Get-Credential try { $Connection = Connect-PnPOnline -ReturnConnection -url "https://tenant/sites/EmergencyResponse" -Credentials $Cred # Do something } catch { write-host -f Red "
tError:" $_.Exception.Message}
finally {
If ($null -ne $Connection) {
Disconnect-PnPOnline -Connection $Connection
}
}`
Please advise/help.

Beta Was this translation helpful? Give feedback.
All reactions