Skip to content

Instantly share code, notes, and snippets.

@LauraKokkarinen
Last active April 20, 2024 08:08
Show Gist options
  • Save LauraKokkarinen/6ed840b89e6eced41fc31e63fb2a32a7 to your computer and use it in GitHub Desktop.
Save LauraKokkarinen/6ed840b89e6eced41fc31e63fb2a32a7 to your computer and use it in GitHub Desktop.
# Configure these four variable values before running the script
$tenantName = "the prefix of your tenant before .sharepoint.com"
$clientId = "the GUID you copied from the Entra ID application registration"
$certPath = "C:\some_local_directory\cert_name.pfx"
$certPassword = "the password you used when generating the certificate"
$adminSiteUrl = "https://" + $tenantName + "-admin.sharepoint.com"
$password = (ConvertTo-SecureString -AsPlainText $certPassword -Force)
Connect-PnPOnline -Url $adminSiteUrl -ClientId $clientId -CertificatePath $certPath -CertificatePassword $password -Tenant "$($tenantName).onmicrosoft.com"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment