Set-PnPContext

Set the ClientContext

Syntax

Set-PnPContext
   -Context <ClientContext>

Description

Sets the Client Context to use by the cmdlets, which allows easy context switching. See examples for details.

Examples

------------------EXAMPLE 1------------------

Connect-PnPOnline -Url $siteAurl -Credentials $credentials
$ctx = Get-PnPContext
Get-PnPList # returns the lists from site specified with $siteAurl
Connect-PnPOnline -Url $siteBurl -Credentials $credentials
Get-PnPList # returns the lists from the site specified with $siteBurl
Set-PnPContext -Context $ctx # switch back to site A
Get-PnPList # returns the lists from site A

Required Parameters

-Context

The ClientContext to set

Type:ClientContext
Position:1
Accept pipeline input:True
Accept wildcard characters:False