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-VETPostExports Microsoft Teams team channel posts to a file in the HTML format. 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. You can 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-Credentialcmdlet. Save the result to the$backupservercredsvariable.$backupservercreds = Get-Credential
Run the
Start-VBOTeamsItemRestoreSessionStarts restore sessions to explore backed-up Microsoft Teams objects and to perform operations with these items. 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 theServerparameter value. Set the$backupservercredsvariable as theCredentialparameter value. Save the result to the$sessionvariable.$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-VBOTeamsItemRestoreSessionReturns active restore sessions started to perform operations with backed-up Microsoft Teams items. 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$sessionvariable.$session = (Get-VBOTeamsItemRestoreSession)[0]
- 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.
- Get a Microsoft Teams organization. To do this, run the
Get-VETOrganizationReturns Microsoft Teams organizations added to Veeam Backup for Microsoft 365. 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 theNameparameter value. This example uses the second approach. Save the result to the$orgvariable.$org = Get-VETOrganization -Session $session -Name "ABCCompany"
- Get a Microsoft Teams team. To do this, run the
Get-VETTeamReturns Microsoft Teams teams. cmdlet. Specify the$orgvariable as theOrganizationparameter 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 theDisplayNameparameter value. This example uses the second approach. Save the result to the$teamvariable.$team = Get-VETTeam -Organization $org -DisplayName "IT"
- Get a Microsoft Teams channel. To do this, run the
Get-VETChannelReturns Microsoft Teams team channels. cmdlet. Specify the$teamvariable as theTeamparameter 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 theDisplayNameparameter value. This example uses the second approach. Save the result to the$channelvariable.$channel = Get-VETChannel -Team $team -DisplayName "General"
- Get a Veeam Explorer for Microsoft Teams restore session.
- 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
DateTimeformat. Save the result to the$datefromvariable.$datefrom = [datetime]"2/16/2026 10:00 AM"
- Specify the time that defines the end of the period for which you want to export posts and convert it to the
DateTimeformat. Save the result to the$datetovariable.$dateto = [datetime]"3/15/2026 2:00 PM"
- Specify the time that defines the start of the period for which you want to export posts and convert it to the
- Run the
Export-VETPostExports Microsoft Teams team channel posts to a file in the HTML format. cmdlet to initiate the restore process. Set the$channelvariable as theChannelparameter value. Set the$datefromvariable as theFromparameter value. Set the$datetovariable as theToparameter value. Specify the path to the exported file on the machine where the PowerShell session is running.Export-VETPost -Channel $channel -Path "C:\export\posts.html" -From $datefrom -To $dateto