Using Microsoft Teams PowerShell Cmdlets With Pia
Pre-Requisitesβ
To use the Microsoft Teams PowerShell cmdlets, you will need to first install the module on your Pia tenant. To do that, follow the instructions in the following article: Install PowerShell Modules on your Pia Tenant
The Code:β
The following script will use the tokens in Pia to initialise a connection to Microsoft Teams and get a list of groups.
conditions:
- name: 'chat'
option_button: 'Test'
option_text: 'Test'
option_category: 'Test'
- name: 'client_filter'
optMode: 'OptOut'
category: 'Test'
steps:
- task: inline_powershell
inputs:
teamsToken: $TEAMS_Api_Token_Client
graphToken: $MSGRAPH_Api_Token_Client
script: |
if (-not $(Get-Command "Connect-MicrosoftTeams" -ErrorAction SilentlyContinue))
{
Import-Module MicrosoftTeams
}
Connect-MicrosoftTeams -AccessTokens @($graphToken, $teamsToken)
Write-Host $(ConvertTo-Json $(Get-Team))