Skip to content

Commit

Permalink
Merge pull request #1799 from gautamdsheth/feature/444
Browse files Browse the repository at this point in the history
Feature #444 - added Get-PnPTeamsChannelFilesFolder
  • Loading branch information
KoenZomers authored May 23, 2022
2 parents bbc09f9 + fd4b334 commit e973bc0
Show file tree
Hide file tree
Showing 5 changed files with 163 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
78 changes: 78 additions & 0 deletions documentation/Get-PnPTeamsChannelFilesFolder.md
Original file line number Diff line number Diff line change
@@ -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 <TeamsTeamPipeBind>] [-Channel <TeamsChannelPipeBind>]
[<CommonParameters>]
```

## 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)
37 changes: 37 additions & 0 deletions src/Commands/Model/Teams/TeamsChannelFilesFolder.cs
Original file line number Diff line number Diff line change
@@ -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; }
}
}
41 changes: 41 additions & 0 deletions src/Commands/Teams/GetTeamsChannelFilesFolder.cs
Original file line number Diff line number Diff line change
@@ -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));
}
}
}
}
6 changes: 6 additions & 0 deletions src/Commands/Utilities/TeamsUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -730,6 +730,12 @@ public static async Task<TeamChannelMember> UpdateChannelMemberAsync(HttpClient
return await GraphHelper.PatchAsync(httpClient, accessToken, $"v1.0/teams/{groupId}/channels/{channelId}/members/{membershipId}", channelMember);
}

public static async Task<TeamsChannelFilesFolder> GetChannelsFilesFolderAsync(HttpClient httpClient, string accessToken, string groupId, string channelId)
{
var collection = await GraphHelper.GetAsync<TeamsChannelFilesFolder>(httpClient, $"v1.0/teams/{groupId}/channels/{channelId}/filesFolder", accessToken);
return collection;
}

#endregion

#region Tabs
Expand Down

0 comments on commit e973bc0

Please sign in to comment.