The below is from Lee Ford’s Get-TeamsPSTNCallRecords script on GitHub. I have used his connection method in my Teams Call Accounting Script which I have also published on GitHub here.
Create an Azure App Registration
Before you can use the tool, you will need to create an Azure AD application with the relevant Graph API permissions:
- Login to Azure portal
- Go to Azure Active Directory > App registrations and select New registration
- Give the app an arbitrary Name and leave the rest as-is and click Register
- Take a copy of the Application ID and Directory ID from the Overview page
- Go to Certificates and secrets and create a New client secret. Again, take a copy of this
- Next, go to API permissions and Add a permission. Select Microsoft Graph and choose Application permissions. Search for CallRecords.Read.All and select Add permissions
- Finally, you need to Grant admin consent for (tenant name)
With the Application ID, Directory ID and Secret to hand, place these in the relevant variables in the .ps1 script: