Last active
January 19, 2021 04:53
-
-
Save JeffBrownTech/01dd81659c301559cf5a63587180678e to your computer and use it in GitHub Desktop.
Code Added to TeamsCallCommunicationApi for an Azure Function
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Create credential object and get access token | |
| $secureClientSecret = ConvertTo-SecureString -String $env:ClientSecret -AsPlainText -Force | |
| $graphApiCreds = New-Object System.Management.Automation.PSCredential($env:ClientId, $secureClientSecret) | |
| $accessToken = Get-GraphApiAccessToken -Credential $graphApiCreds -TenantId $env:TenantId | |
| # Get previous 2 day of records | |
| $pstnRecords = Get-TeamsPstnCalls -Days 2 -AccessToken $accessToken | |
| $pstnRecordCount = $pstnRecords.Count | |
| $counter = 1 | |
| Write-Information -MessageData "Found $pstnRecordCount records" | |
| foreach ($record in $pstnRecords) { | |
| Write-Information -MessageData "Processing PSTN record $counter of $pstnRecordCount" | |
| # Sets the table's partition key to record's current year-month-day | |
| $partitionKey = $record.startDateTime.ToString('yyyy-MM-dd') | |
| $tableData = [PsCustomObject]@{ | |
| partitionKey = $partitionKey | |
| rowKey = $record.id | |
| callId = $record.callId | |
| userId = $record.userId | |
| userPrincipalName = $record.userPrincipalName | |
| userDisplayName = $record.userDisplayName | |
| startDateTime = $record.startDateTime | |
| endDateTime = $record.endDateTime | |
| durationSeconds = $record.duration | |
| charge = $record.charge | |
| currency = $record.currency | |
| callType = $record.callType | |
| calleeNumber = $record.calleeNumber | |
| callerNumber = $record.callerNumber | |
| usageCountryCode = $record.usageCountryCode | |
| tenantCountryCode = $record.tenantCountryCode | |
| connectionCharge = $record.connectionCharge | |
| destinationContext = $record.destinationContext | |
| destinationName = $record.destinationName | |
| conferenceId = $record.conferenceId | |
| licenseCapability = $record.licenseCapability | |
| inventoryType = $record.inventoryType | |
| } | |
| Push-OutputBinding -Name callPlanOutputTable -Value $tableData | |
| $counter++ | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment