This document describes how to create the Microsoft Entra ID app registration that the eSHARE classification scripts sign in with, and the tenant configuration file that points the scripts at it. It is separate from the eSHARE app registration created when you connected eSHARE to Microsoft 365, and is used only by the column scripts. You need to do this once per tenant. The following steps will be reviewed:
PREREQUISITES:
Creating the app requires an Application Administrator or Global Administrator. Granting admin consent requires a Global Administrator or Privileged Role Administrator. Complete Prepare the Workstation first.
Create the Certificate
The app signs in with a certificate instead of a password. Create it on the computer that will run the scripts.
In PowerShell 7, create a self-signed certificate in your user certificate store and export its public key:
$cert = New-SelfSignedCertificate -Subject "CN=eSHARE Classify SPO Columns" `
-CertStoreLocation "Cert:\CurrentUser\My" -KeyExportPolicy Exportable `
-KeySpec Signature -KeyLength 2048 -HashAlgorithm SHA256 -NotAfter (Get-Date).AddYears(1)
Export-Certificate -Cert $cert -FilePath "$HOME\eSHARE-Classify-SPO-Columns.cer"
$cert.ThumbprintCopy the thumbprint that is displayed. You will need it for the tenant configuration file.
Note:
On macOS or Linux, the scripts need a .pfx file instead of a thumbprint. Create one with OpenSSL, or export the Windows certificate with
Export-PfxCertificate. Keep the .pfx outside any shared or synced folder, as it holds the app's private key.
Register the App
Sign in to the Microsoft Entra admin center for your cloud: entra.microsoft.com for Commercial and GCC, or entra.microsoft.us for GCC High. Navigate to 'Entra ID' > 'App registrations'.
Select 'New registration' and complete the form:
In 'Name', enter eSHARE Classify SPO Columns.
In 'Supported account types', select 'Accounts in this organizational directory only'.
Select the 'Register' button.
On the app's 'Overview' page, copy the 'Application (client) ID' and the 'Directory (tenant) ID'.
Navigate to 'Certificates & secrets' > 'Certificates' and select 'Upload certificate'.
Choose the eSHARE-Classify-SPO-Columns.cer file from your user folder and select 'Add'. Confirm that the thumbprint shown matches the one you copied.
Add the Permissions and Grant Consent
The app needs two application permissions:
API | Permission (Application) | Used by |
|---|---|---|
SharePoint | Sites.FullControl.All | Deploying the columns and site templates, and the inventory's search schema export |
Microsoft Graph | Sites.Read.All | The inventory's list of sites and columns |
In the app, navigate to 'API permissions' and select 'Add a permission'.
Select 'SharePoint' > 'Application permissions', check 'Sites.FullControl.All' and select 'Add permissions'.
Select 'Add a permission' again, then 'Microsoft Graph' > 'Application permissions', check 'Sites.Read.All' and select 'Add permissions'.
Select 'Grant admin consent for [your organization]' and confirm. Both permissions show the status 'Granted'.

Note:
Sites.FullControl.All must be added under the SharePoint API. The Microsoft Graph permission of the same name doesn't cover the calls the scripts make.
Create the Tenant Configuration File
Choose a folder name for your tenant inside C:\eSHARE-Classification, e.g. Contoso. The configuration file goes in this folder, and the scripts save their reports there.
In PowerShell 7, create the folder and open a new configuration file in Notepad. Select 'Yes' when Notepad asks to create the file:
New-Item -ItemType Directory -Path C:\eSHARE-Classification\Contoso -Force | Out-Null
notepad C:\eSHARE-Classification\Contoso\contoso.tenant.jsonPaste the version for your cloud into the file and replace the placeholders with your values. The only difference is the last line, 'Cloud'; the scripts use it to connect to the right endpoints.
{
"TenantName": "contoso",
"TenantId": "<Directory (tenant) ID>",
"ClientId": "<Application (client) ID>",
"CertificatePath": "",
"CertificateThumbprint": "<certificate thumbprint>",
"ProvisioningClientId": "<Application (client) ID>",
"ProvisioningCertificatePath": "",
"ProvisioningCertificateThumbprint": "<certificate thumbprint>",
"Cloud": "Commercial"
}{
"TenantName": "contoso",
"TenantId": "<Directory (tenant) ID>",
"ClientId": "<Application (client) ID>",
"CertificatePath": "",
"CertificateThumbprint": "<certificate thumbprint>",
"ProvisioningClientId": "<Application (client) ID>",
"ProvisioningCertificatePath": "",
"ProvisioningCertificateThumbprint": "<certificate thumbprint>",
"Cloud": "GCCHigh"
}Use these values:
'TenantName': the part of your SharePoint address before .sharepoint.com, or .sharepoint.us in GCC High (for https://contoso.sharepoint.us, enter contoso).
'ClientId' and 'ProvisioningClientId': the Application (client) ID, the same value in both.
'CertificateThumbprint' and 'ProvisioningCertificateThumbprint': the certificate thumbprint, the same value in both.
'Cloud': Commercial, GCC (GCC uses the commercial endpoints) or GCCHigh. For DoD tenants, contact eSHARE support before you start.
Save the file.
Note:
The file holds no secrets. On macOS or Linux, set 'CertificatePath' and 'ProvisioningCertificatePath' to the .pfx file (e.g. ~/Certs/eshare-classification.pfx) and leave the thumbprints empty; the scripts ask for the .pfx password each time they run.
Test the Connection
In a new PowerShell 7 window, connect to SharePoint and to Microsoft Graph as the app, using the version for your cloud. Replace the placeholders with your values:
Import-Module PnP.PowerShell
$clientId = "<Application (client) ID>"; $tenantId = "<Directory (tenant) ID>"; $thumb = "<certificate thumbprint>"
Connect-PnPOnline -Url "https://contoso-admin.sharepoint.com" -ClientId $clientId -Tenant $tenantId -Thumbprint $thumb
Get-PnPTenantSite | Select-Object -First 3 Url
Connect-MgGraph -ClientId $clientId -TenantId $tenantId -CertificateThumbprint $thumb -NoWelcome
Get-MgSite -SiteId root | Select-Object DisplayName, WebUrlImport-Module PnP.PowerShell
$clientId = "<Application (client) ID>"; $tenantId = "<Directory (tenant) ID>"; $thumb = "<certificate thumbprint>"
Connect-PnPOnline -Url "https://contoso-admin.sharepoint.us" -AzureEnvironment USGovernmentHigh -ClientId $clientId -Tenant $tenantId -Thumbprint $thumb
Get-PnPTenantSite | Select-Object -First 3 Url
Connect-MgGraph -Environment USGov -ClientId $clientId -TenantId $tenantId -CertificateThumbprint $thumb -NoWelcome
Get-MgSite -SiteId root | Select-Object DisplayName, WebUrlConfirm that both commands return site addresses from your tenant. An Unauthorized or Access denied error usually means admin consent hasn't been granted, or the permission was added under the wrong API.
Note:
The certificate is valid for one year. Before it expires, create a new certificate, upload it to the app registration, and update the thumbprints in the tenant configuration file.