Search Results for

    Show / Hide Table of Contents

    Get-PnPContext

    SYNOPSIS

    Returns the current SharePoint Online CSOM context

    SYNTAX

    Get-PnPContext [-Connection <PnPConnection>] 
    

    DESCRIPTION

    Returns a SharePoint Online Client Side Object Model (CSOM) context

    EXAMPLES

    EXAMPLE 1

    $ctx = Get-PnPContext
    

    This will put the current context in the $ctx variable.

    EXAMPLE 2

    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
    

    PARAMETERS

    -Connection

    Optional connection to be used by the cmdlet. Retrieve the value for this parameter by either specifying -ReturnConnection on Connect-PnPOnline or by executing Get-PnPConnection. If not provided, the context of the connection will be retrieved from the current connection.

    Type: PnPConnection
    Parameter Sets: (All)
    
    Required: False
    Position: Named
    Default value: None
    Accept pipeline input: False
    Accept wildcard characters: False
    

    RELATED LINKS

    Microsoft 365 Patterns and Practices

    Back to top Generated by DocFX spacer