internal/functions/Select-Site.ps1

function Select-Site {
    <#
    .SYNOPSIS
        Switches the current connection context of Sharepoint to the specified site.
     
    .DESCRIPTION
        Switches the current connection context of Sharepoint to the specified site.
        This reuses the previously specified connection information.
     
    .PARAMETER Url
        The site url to switch to.
     
    .EXAMPLE
        PS C:\> Select-Site -Url https://contoso.sharepoint.com/Sites/WorldConquestv4
 
        Switches the current connection context to the specified site.
    #>

    [CmdletBinding()]
    param (
        [Parameter(Mandatory = $true)]
        [string]
        $Url
    )

    if (-not $script:thumbprint) {
        throw "Not connected yet, call 'Connect-Sharepoint' to connect!"
    }

    Connect-PnPOnline -Tenant $script:tenantID -ClientId $script:clientID -Thumbprint $script:thumbprint -TenantAdminUrl $script:adminUrl -Url $Url -ReturnConnection
}