Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature #444 - added Get-PnPTeamsChannelFilesFolder #1799

Merged
merged 4 commits into from
May 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
- Added `Add-PnPTeamsChannelUser` which allows members and owners to be added to private channels in Teams [#1735](https://github.com/pnp/powershell/pull/1735)
- Added `ExcludeVisualPromotedResults` parameter to `Get-PnPSearchConfiguration` which excludes promoted results [#1750](https://github.com/pnp/powershell/pull/1750)
- 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 @@ -712,6 +712,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