diff --git a/CHANGELOG.md b/CHANGELOG.md index 2da088cf7..3c4dbff68 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/). - Added `-SensitivityLabels` parameter to `New-PnPTeamsTeam` and `New-PnPMicrosoft365Group` cmdlets to apply sensitivity label to the Microsoft 365 Group and Team. - Added `-SensitivityLabels` parameter to `Set-PnPMicrosoft365Group` cmdlets to apply sensitivity label to the Microsoft 365 Group and Team. - Added `MediaTranscription` parameter to `Set-PnPTenantSite` and `Set-PnPSite` cmdlets which when enabled allows videos to have transcripts generated on demand or generated automatically in certain scenarios +- Added `Get-PnPTeamsChannelFilesFolder` cmdlet to retrieve metadata for the location where files of a Teams channel are stored. [#1799](https://github.com/pnp/powershell/pull/1799) - Added `Get-PnPVivaConnectionsDashboardACE` to retrieve the Adaptive Card extensions from the Viva connections dashboard page. [#1805](https://github.com/pnp/powershell/pull/1805) - Added `Add-PnPVivaConnectionsDashboardACE` to add an Adaptive Card extension to the Viva connections dashboard page. [#1805](https://github.com/pnp/powershell/pull/1805) - Added `Update-PnPVivaConnectionsDashboardACE` to update an Adaptive Card extension in the Viva connections dashboard page. [#1805](https://github.com/pnp/powershell/pull/1805) diff --git a/documentation/Get-PnPTeamsChannelFilesFolder.md b/documentation/Get-PnPTeamsChannelFilesFolder.md new file mode 100644 index 000000000..011c9ce3e --- /dev/null +++ b/documentation/Get-PnPTeamsChannelFilesFolder.md @@ -0,0 +1,78 @@ +--- +Module Name: PnP.PowerShell +title: Get-PnPTeamsChannelFilesFolder +schema: 2.0.0 +applicable: SharePoint Online +external help file: PnP.PowerShell.dll-Help.xml +online version: https://pnp.github.io/powershell/cmdlets/Get-PnPTeamsChannelFilesFolder.html +--- + +# Get-PnPTeamsChannelFilesFolder + +## SYNOPSIS + +**Required Permissions** + + * Microsoft Graph API : Group.Read.All + +Gets the metadata for the location where the files of a channel are stored. + +## SYNTAX + +```powershell +Get-PnPTeamsChannel [-Team ] [-Channel ] + [] +``` + +## DESCRIPTION + +## EXAMPLES + +### EXAMPLE 1 +```powershell +Get-PnPTeamsChannelFilesFolder -Team "Sales Team" -Identity "Test Channel" +``` + +Retrieves the folder metadata for the channel called 'Test Channel' located in the Team named 'Sales Team' + +### EXAMPLE 2 +```powershell +Get-PnPTeamsChannelFilesFolder -Team a6c1e0d7-f579-4993-81ab-4b666f8edea8 -Identity "19:796d063b63e34497aeaf092c8fb9b44e@thread.skype" +``` + +Retrieves the folder metadata for the channel specified by its channel id + +## PARAMETERS + +### -Channel +The id or name of the channel to retrieve. + +```yaml +Type: TeamsChannelPipeBind +Parameter Sets: (All) + +Required: True +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Team +Specify the group id, mailNickname or display name of the team to use. + +```yaml +Type: TeamsTeamPipeBind +Parameter Sets: (All) + +Required: True +Position: Named +Default value: None +Accept pipeline input: True (ByValue) +Accept wildcard characters: False +``` + +## RELATED LINKS + +[Microsoft 365 Patterns and Practices](https://aka.ms/m365pnp) + diff --git a/src/Commands/Model/Teams/TeamsChannelFilesFolder.cs b/src/Commands/Model/Teams/TeamsChannelFilesFolder.cs new file mode 100644 index 000000000..458088762 --- /dev/null +++ b/src/Commands/Model/Teams/TeamsChannelFilesFolder.cs @@ -0,0 +1,37 @@ +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Text; + +namespace PnP.PowerShell.Commands.Model.Teams +{ + public partial class TeamsChannelFilesFolder + { + public string id { get; set; } + public DateTime createdDateTime { get; set; } + public DateTime lastModifiedDateTime { get; set; } + public string name { get; set; } + public string webUrl { get; set; } + public int size { get; set; } + public TeamChannelParentReference parentReference { get; set; } + public TeamChannelFileSystemInfo fileSystemInfo { get; set; } + public TeamChannelFolder folder { get; set; } + } + + public partial class TeamChannelParentReference + { + public string driveId { get; set; } + public string driveType { get; set; } + } + + public partial class TeamChannelFileSystemInfo + { + public DateTime createdDateTime { get; set; } + public DateTime lastModifiedDateTime { get; set; } + } + + public partial class TeamChannelFolder + { + public int childCount { get; set; } + } +} diff --git a/src/Commands/Teams/GetTeamsChannelFilesFolder.cs b/src/Commands/Teams/GetTeamsChannelFilesFolder.cs new file mode 100644 index 000000000..f18a94b55 --- /dev/null +++ b/src/Commands/Teams/GetTeamsChannelFilesFolder.cs @@ -0,0 +1,41 @@ +using PnP.PowerShell.Commands.Attributes; +using PnP.PowerShell.Commands.Base; +using PnP.PowerShell.Commands.Base.PipeBinds; +using System; +using System.Collections.Generic; +using System.Management.Automation; + +namespace PnP.PowerShell.Commands.Teams +{ + [Cmdlet(VerbsCommon.Get, "PnPTeamsChannelFilesFolder")] + [RequiredMinimalApiPermissions("Group.Read.All")] + public class GetTeamsChannelFilesFolder : PnPGraphCmdlet + { + [Parameter(Mandatory = true, ValueFromPipeline = true)] + public TeamsTeamPipeBind Team; + + [Parameter(Mandatory = true)] + public TeamsChannelPipeBind Channel; + + protected override void ExecuteCmdlet() + { + var groupId = Team.GetGroupId(HttpClient, AccessToken); + if (groupId != null) + { + + var channelId = Channel.GetId(HttpClient, AccessToken, groupId); + if (channelId == null) + { + throw new PSArgumentException("Channel not found"); + } + + WriteObject(Utilities.TeamsUtility.GetChannelsFilesFolderAsync(HttpClient, AccessToken, groupId, channelId).GetAwaiter().GetResult()); + + } + else + { + throw new PSArgumentException("Team not found", nameof(Team)); + } + } + } +} diff --git a/src/Commands/Utilities/TeamsUtility.cs b/src/Commands/Utilities/TeamsUtility.cs index 71a7bea11..a579b3e57 100644 --- a/src/Commands/Utilities/TeamsUtility.cs +++ b/src/Commands/Utilities/TeamsUtility.cs @@ -730,6 +730,12 @@ public static async Task UpdateChannelMemberAsync(HttpClient return await GraphHelper.PatchAsync(httpClient, accessToken, $"v1.0/teams/{groupId}/channels/{channelId}/members/{membershipId}", channelMember); } + public static async Task GetChannelsFilesFolderAsync(HttpClient httpClient, string accessToken, string groupId, string channelId) + { + var collection = await GraphHelper.GetAsync(httpClient, $"v1.0/teams/{groupId}/channels/{channelId}/filesFolder", accessToken); + return collection; + } + #endregion #region Tabs