Examples of Use
This section describes how to use a PowerShell script to export Teams channel posts published in a specific time frame to the machine where the PowerShell session is running.
To export Microsoft Teams channel posts, use the Export-VETPost cmdlet. This cmdlet includes two parameter sets: a parameter set to export specific posts, and a parameter set to export posts of a specified channel. This example uses the second parameter set.
To perform this export operation, specify the following settings:
- Microsoft Teams channel — to specify the channel whose posts you want to export.
- Time range of the posts — to specify the posts that you want to export.
The cmdlet treats these settings as objects. We will get these objects and save them to variables:
- To specify the Microsoft Teams channel, do the following:
- Get a Veeam Explorer for Microsoft Teams restore session.
- If this is a fresh PowerShell environment, you must first start a Veeam Explorer for Microsoft Teams restore session. This example uses the remote session method, which works with Veeam Explorer for Microsoft Teams that comes with both Veeam Backup & Replication and Veeam Backup for Microsoft 365 installations. The machine where the PowerShell session is running will connect to the Veeam Backup for Microsoft 365 server that created the backup.
To provide the connection credentials, run the Get-Credential cmdlet. Save the result to the $backupservercreds variable.
Run the Start-VBOTeamsItemRestoreSession cmdlet to start a Veeam Explorer for Microsoft Teams restore session. Specify the DNS name or IP address of the Veeam Backup for Microsoft 365 backup server as the Server parameter value. Set the $backupservercreds variable as the Credential parameter value. Save the result to the $session variable.
$session = Start-VBOTeamsItemRestoreSession -Server "srv96.tech.local" -Credential $backupservercreds |
- If you already have a restore session started with the necessary restore point, just run the Get-VBOTeamsItemRestoreSession cmdlet to get an array of active restore sessions. If you have multiple active restore sessions, specify the position of the necessary restore session in the array of returned sessions. This example uses the first restore session in the array. Save the result to the $session variable.
- Get a Microsoft Teams organization. To do this, run the Get-VETOrganization cmdlet. If there are multiple organizations in the restore session, specify the position of the necessary organization in the array of returned organizations, or specify the organization name as the Name parameter value. This example uses the second approach. Save the result to the $org variable.
- Get a Microsoft Teams team. To do this, run the Get-VETTeam cmdlet. Specify the $org variable as the Organization parameter value. If there are multiple teams in the organization, specify the position of the necessary team in the array of returned teams, or specify the team name as the DisplayName parameter value. This example uses the second approach. Save the result to the $team variable.
- Get a Microsoft Teams channel. To do this, run the Get-VETChannel cmdlet. Specify the $team variable as the Team parameter value. If there are multiple channels in the team, specify the position of the necessary channel in the array of returned channels, or specify the channel name as the DisplayName parameter value. This example uses the second approach. Save the result to the $channel variable.
- Get the time range of the necessary posts. To do this, do the following:
- Specify the time that defines the start of the period for which you want to export posts and convert it to the DateTime format. Save the result to the $datefrom variable.
- Specify the time that defines the end of the period for which you want to export posts and convert it to the DateTime format. Save the result to the $dateto variable.
- Run the Export-VETPost cmdlet to initiate the restore process. Set the $channel variable as the Channel parameter value. Set the $datefrom variable as the From parameter value. Set the $dateto variable as the To parameter value. Specify the path to the exported file on the machine where the PowerShell session is running.