Skip to content
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
- Added `New-PnPContainerType` cmdlet to create a new SharePoint container type. [#3669](https://github.com/pnp/powershell/pull/3669)
- Added `Remove-PnPContainerType` cmdlet which removes a specific container type. [#3689](https://github.com/pnp/powershell/pull/3689/)
- Added `Restore-PnPDeletedContainer` cmdlet which recovers a deleted Container from the Recycle Bin. [#3661](https://github.com/pnp/powershell/pull/3661)
- Added the ModerationSettings to be returned with `Get-PnPTeamsChannel` when passing in `-IncludeModerationSettings` and using `-Identity <channelId>` [#3580](https://github.com/pnp/powershell/pull/3580)
- Added `AllowNewMessageFromBots`, `AllowNewMessageFromConnectors`, `ReplyRestriction` and `UserNewMessageRestriction` to `Set-PnPTeamsChannel` which allows setting the moderation settings on a Teams channel [#3580](https://github.com/pnp/powershell/pull/3580)
- Added `Get-PnPWebPermission` cmdlet which retrieves permission given by user for specific web. [#3685](https://github.com/pnp/powershell/pull/3685)
- Added `-HorizontalQuickLaunch` parameter to `Set-PnPWeb` cmdlet to allow navigation orientation to be horizontal. [#3722](https://github.com/pnp/powershell/pull/3722)
- Added `Set-PnPRetentionLabel` and `Reset-PnPRetentionLabel` cmdlets to support setting a retention label on one or more items [#3599](https://github.com/pnp/powershell/pull/3599)
Expand Down
28 changes: 25 additions & 3 deletions documentation/Get-PnPTeamsChannel.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,16 @@ Gets the channels for a specified Team.
## SYNTAX

```powershell
Get-PnPTeamsChannel -Team <TeamsTeamPipeBind> [-Identity <TeamsChannelPipeBind>]
Get-PnPTeamsChannel -Team <TeamsTeamPipeBind> [-Identity <TeamsChannelPipeBind>] [-IncludeModerationSettings <SwitchParameter>]

```

## DESCRIPTION

Allows to retrieve list of channels for a specified team.

Note that the ModerationSettings are only being returned when providing the channel Id of a specific channel through -Identity and by providing -IncludeModerationSettings (Example 4). They will not be returned when retrieving all channels for a team or when omitting -IncludeModerationSettings. This is because of a design choice in Microsoft Graph and the moderationsettings currently only being available through its beta endpoint, which will be used when -IncludeModerationSettings is provided.

## EXAMPLES

### EXAMPLE 1
Expand All @@ -51,6 +53,13 @@ Get-PnPTeamsChannel -Team a6c1e0d7-f579-4993-81ab-4b666f8edea8 -Identity "19:796

Retrieves the channel specified by its channel id

### EXAMPLE 4
```powershell
Get-PnPTeamsChannel -Team a6c1e0d7-f579-4993-81ab-4b666f8edea8 -Identity "19:796d063b63e34497aeaf092c8fb9b44e@thread.skype" -IncludeModerationSettings
```

Retrieves the channel specified by its channel id which will include the ModerationSettings

## PARAMETERS

### -Identity
Expand Down Expand Up @@ -81,7 +90,20 @@ Accept pipeline input: True (ByValue)
Accept wildcard characters: False
```

## RELATED LINKS
### -IncludeModerationSettings
When provided, it will use the beta endpoint of Microsoft Graph to retrieve the information. This will include the ModerationSettings if used in combination with -Identity <channelId>.

```yaml
Type: SwitchParameter
Parameter Sets: (All)

[Microsoft 365 Patterns and Practices](https://aka.ms/m365pnp)
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

## RELATED LINKS

[Microsoft 365 Patterns and Practices](https://aka.ms/m365pnp)
61 changes: 58 additions & 3 deletions documentation/Set-PnPTeamsChannel.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Updates an existing Teams Channel
## SYNTAX

```powershell
Set-PnPTeamsChannel -Team <TeamsTeamPipeBind> -Identity <TeamsChannelPipeBind> [-DisplayName <String>] [-Description <String>] [-IsFavoriteByDefault <Boolean>]
Set-PnPTeamsChannel -Team <TeamsTeamPipeBind> -Identity <TeamsChannelPipeBind> [-DisplayName <String>] [-Description <String>] [-IsFavoriteByDefault <Boolean>] [-AllowNewMessageFromBots <Boolean>] [-AllowNewMessageFromConnectors <Boolean>] [-ReplyRestriction <TeamChannelModerationSettingReplyRestriction>] [-UserNewMessageRestriction <TeamChannelModerationSettingNewMessageRestriction>]

```

Expand All @@ -46,6 +46,62 @@ Updates the channel called 'MyChannel' to make it visible to members.

## PARAMETERS

### -AllowNewMessageFromBots
Allows configuring if bots are allowed to post messages in the channel

```yaml
Type: Boolean
Parameter Sets: (All)

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -AllowNewMessageFromConnectors
Allows configuring if connectors are allowed to post messages in the channel

```yaml
Type: Boolean
Parameter Sets: (All)

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -ReplyRestriction
Allows configuring who can reply to posts in the channel

```yaml
Type: TeamChannelModerationSettingReplyRestriction
Parameter Sets: (All)

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -UserNewMessageRestriction
Allows configuring who can post new messages in the channel

```yaml
Type: TeamChannelModerationSettingNewMessageRestriction
Parameter Sets: (All)

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -Description
Changes the description of the specified channel.

Expand Down Expand Up @@ -118,5 +174,4 @@ Accept wildcard characters: False

## RELATED LINKS

[Microsoft 365 Patterns and Practices](https://aka.ms/m365pnp)

[Microsoft 365 Patterns and Practices](https://aka.ms/m365pnp)
19 changes: 10 additions & 9 deletions src/Commands/Base/PipeBinds/TeamsChannelPipeBind.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,21 +49,22 @@ public string GetId(PnPConnection connection, string accessToken, string groupId
}
}

public TeamChannel GetChannel(PnPConnection connection, string accessToken, string groupId)
public TeamChannel GetChannel(PnPConnection connection, string accessToken, string groupId, bool useBeta = false)
{
var channels = TeamsUtility.GetChannelsAsync(accessToken, connection, groupId).GetAwaiter().GetResult();
if(channels != null && channels.Any())
if (!string.IsNullOrEmpty(_id))
{
if(!string.IsNullOrEmpty(_id))
{
return channels.FirstOrDefault(c => c.Id.Equals(_id, StringComparison.OrdinalIgnoreCase));
} else
var channel = TeamsUtility.GetChannelAsync(accessToken, connection, groupId, _id, useBeta).GetAwaiter().GetResult();
return channel;
}
else
{
var channels = TeamsUtility.GetChannelsAsync(accessToken, connection, groupId, useBeta).GetAwaiter().GetResult();
if (channels != null && channels.Any())
{
return channels.FirstOrDefault(c => c.DisplayName.Equals(_displayName, StringComparison.OrdinalIgnoreCase));
}
return null;
}
return null;
}

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
namespace PnP.PowerShell.Commands.Enums
{
/// <summary>
/// All allowed options for Team Channel post new message restrictions within the moderation settings of a Microsoft Teams team
/// </summary>
/// <remarks>Documentation: https://learn.microsoft.com/graph/api/resources/channelmoderationsettings#properties</remarks>
public enum TeamChannelModerationSettingNewMessageRestriction
{
/// <summary>
/// Everyone can create new posts in the channel
/// </summary>
Everyone,

/// <summary>
/// Everyone except guests can create new posts in the channel
/// </summary>
EveryoneExceptGuests,

/// <summary>
/// Moderators can create new posts in the channel
/// </summary>
Moderators
}
}
19 changes: 19 additions & 0 deletions src/Commands/Enums/TeamChannelModerationSettingReplyRestriction.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
namespace PnP.PowerShell.Commands.Enums
{
/// <summary>
/// All allowed options for Team Channel reply restrictions within the moderation settings of a Microsoft Teams team
/// </summary>
/// <remarks>Documentation: https://learn.microsoft.com/graph/api/resources/channelmoderationsettings#properties</remarks>
public enum TeamChannelModerationSettingReplyRestriction
{
/// <summary>
/// Everyone can reply in the channel
/// </summary>
Everyone,

/// <summary>
/// Only authors and moderators can reply in the channel
/// </summary>
AuthorAndModerators
}
}
2 changes: 1 addition & 1 deletion src/Commands/Microsoft365Groups/NewMicrosoft365Group.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ protected override void ExecuteCmdlet()
throw new PSArgumentException("File specified for logo does not exist.");
}
}
var newGroup = new Microsoft365Group()
var newGroup = new Microsoft365Group
{
DisplayName = DisplayName,
Description = Description,
Expand Down
39 changes: 39 additions & 0 deletions src/Commands/Model/Teams/ChannelModerationSettings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
using System.Text.Json.Serialization;

namespace PnP.PowerShell.Commands.Model.Teams
{
/// <summary>
/// Moderation settings on a Teams Channel
/// </summary>
/// <remarks>Documentation at https://learn.microsoft.com/graph/api/resources/channelmoderationsettings</remarks>
public partial class ChannelModerationSettings
{
#region Public Members

/// <summary>
/// Indicates whether bots are allowed to post messages
/// </summary>
[JsonPropertyName("allowNewMessageFromBots")]
public bool? AllowNewMessageFromBots { get; set; }

/// <summary>
/// Indicates whether connectors are allowed to post messages
/// </summary>
[JsonPropertyName("allowNewMessageFromConnectors")]
public bool? AllowNewMessageFromConnectors { get; set; }

/// <summary>
/// Indicates who is allowed to reply to the teams channel
/// </summary>
[JsonPropertyName("replyRestriction")]
public Enums.TeamChannelModerationSettingReplyRestriction? ReplyRestriction { get; set; }

/// <summary>
/// Indicates who is allowed to post messages to teams channel
/// </summary>
[JsonPropertyName("userNewMessageRestriction")]
public Enums.TeamChannelModerationSettingNewMessageRestriction? UserNewMessageRestriction { get; set; }

#endregion
}
}
2 changes: 1 addition & 1 deletion src/Commands/Model/Teams/Team.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using PnP.PowerShell.Commands.Model.Graph;
using PnP.PowerShell.Commands.Utilities.JSON;
using System;
using System.Collections.Generic;
using System.Text.Json.Serialization;
Expand All @@ -12,6 +11,7 @@ namespace PnP.PowerShell.Commands.Model.Teams
public class Team
{
#region Public Members

public string DisplayName { get; set; }

public string Classification { get; set; }
Expand Down
8 changes: 8 additions & 0 deletions src/Commands/Model/Teams/TeamChannel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,16 @@ public partial class TeamChannel
/// </summary>
public string Id { get; set; }

/// <summary>
/// Members of a channel
/// </summary>
public List<TeamChannelMember> Members { get; set; }

/// <summary>
/// Settings for moderating posts in a Teams Channel
/// </summary>
public ChannelModerationSettings ModerationSettings { get; set; } = new();

#endregion
}
}
8 changes: 1 addition & 7 deletions src/Commands/Model/Teams/TeamGuestSettings.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace PnP.PowerShell.Commands.Model.Teams
namespace PnP.PowerShell.Commands.Model.Teams
{
public partial class TeamGuestSettings
{
Expand Down
22 changes: 10 additions & 12 deletions src/Commands/Teams/GetTeamsChannel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,20 @@ public class GetTeamsChannel : PnPGraphCmdlet
[Parameter(Mandatory = false)]
public TeamsChannelPipeBind Identity;

[Parameter(Mandatory = false)]
public SwitchParameter IncludeModerationSettings;

protected override void ExecuteCmdlet()
{
var groupId = Team.GetGroupId(Connection, AccessToken);
if (groupId != null)
var groupId = Team.GetGroupId(Connection, AccessToken) ?? throw new PSArgumentException("Team not found", nameof(Team));

if (ParameterSpecified(nameof(Identity)))
{
if (ParameterSpecified(nameof(Identity)))
{
WriteObject(Identity.GetChannel(Connection, AccessToken, groupId));
}
else
{
WriteObject(TeamsUtility.GetChannelsAsync(AccessToken, Connection, groupId).GetAwaiter().GetResult(), true);
}
} else
WriteObject(Identity.GetChannel(Connection, AccessToken, groupId, useBeta: IncludeModerationSettings.ToBool()));
}
else
{
throw new PSArgumentException("Team not found", nameof(Team));
WriteObject(TeamsUtility.GetChannelsAsync(AccessToken, Connection, groupId, useBeta: IncludeModerationSettings.ToBool()).GetAwaiter().GetResult(), true);
}
}
}
Expand Down
Loading