Skip to content

Commit d387980

Browse files
authored
Merge pull request #1935 from milanholemans/getplannerplan-planid
Introduce plan ID parameter for `Get-PnPPlannerPlan`
2 parents 34f070d + d56c221 commit d387980

File tree

3 files changed

+54
-12
lines changed

3 files changed

+54
-12
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
4242
- Added `-IncludeContentType` parameter, which if specified will retrieve content type information of the list items. [#1921](https://github.com/pnp/powershell/pull/1921)
4343
- Added optional `-ValidateConnection` to `Connect-PnPOnline` which will check if the site you are connecting to exists and if not, will throw an exception [#1924](https://github.com/pnp/powershell/pull/1924)
4444
- Added `AllowTenantMoveWithDataMigration` to `Get-PnPPlannerConfiguration` and `Set-PnPPlannerConfiguration` [#1934](https://github.com/pnp/powershell/pull/1934)
45+
- Added the ability to retrieve a Planner plan by only its Id using `Get-PnPPlannerPlan -Identity <id>` [#1935](https://github.com/pnp/powershell/pull/1935)
4546
- Added `Add-PnPListItemAttachment` cmdlet to provide ability to upload a file as an attachment to a SharePoint list item. [#1932](https://github.com/pnp/powershell/pull/1932)
4647
- Added `Remove-PnPListItemAttachment` cmdlet to provide ability to delete a list item attachment. [#1932](https://github.com/pnp/powershell/pull/1932)
4748
- Added `Get-PnPListItemAttachment` cmdlet to download the attachments from a list item. [#1932](https://github.com/pnp/powershell/pull/1932)

documentation/Get-PnPPlannerPlan.md

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,18 @@ Returns all or a specific Planner plan for a Microsoft 365 Group.
2020

2121
## SYNTAX
2222

23+
### By Group
2324
```powershell
2425
Get-PnPPlannerPlan -Group <PlannerGroupPipeBind> [-Identity <PlannerPlanPipeBind>] [-ResolveIdentities]
2526
[<CommonParameters>]
2627
```
2728

29+
### By Plan Id
30+
```powershell
31+
Get-PnPPlannerPlan -Id <String> [-ResolveIdentities]
32+
[<CommonParameters>]
33+
```
34+
2835
## DESCRIPTION
2936
This cmdlet returns all or a specific Planner plan for a Microsoft 365 Group.
3037

@@ -44,14 +51,21 @@ Get-PnPPlannerPlan -Group "Marketing" -Identity "Conference Plan"
4451

4552
Returns the specified plan for the Marketing group.
4653

54+
### Example 3
55+
```powershell
56+
Get-PnPPlannerPlan -Id "gndWOTSK60GfPQfiDDj43JgACDCb" -ResolveIdentities
57+
```
58+
59+
Rerturns the plan with specified ID with resolved identities.
60+
4761
## PARAMETERS
4862

4963
### -Group
5064
Specify the group containing the plans
5165

5266
```yaml
5367
Type: PlannerGroupPipeBind
54-
Parameter Sets: (All)
68+
Parameter Sets: By Group
5569
Aliases:
5670

5771
Required: True
@@ -66,7 +80,7 @@ If specified the plan with this ID or Name will be returned.
6680
6781
```yaml
6882
Type: PlannerPlanPipeBind
69-
Parameter Sets: (All)
83+
Parameter Sets: By Group
7084
Aliases:
7185

7286
Required: False
@@ -76,6 +90,21 @@ Accept pipeline input: False
7690
Accept wildcard characters: False
7791
```
7892
93+
### -Id
94+
If specified the plan with this ID will be returned.
95+
96+
```yaml
97+
Type: String
98+
Parameter Sets: By Plan Id
99+
Aliases:
100+
101+
Required: True
102+
Position: Named
103+
Default value: None
104+
Accept pipeline input: False
105+
Accept wildcard characters: False
106+
```
107+
79108
### -ResolveIdentities
80109
Show user display names instead of user IDs.
81110

src/Commands/Planner/GetPlannerPlan.cs

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,54 @@
1-
using System.Management.Automation;
2-
using Microsoft.Graph;
31
using PnP.PowerShell.Commands.Attributes;
42
using PnP.PowerShell.Commands.Base;
53
using PnP.PowerShell.Commands.Base.PipeBinds;
64
using PnP.PowerShell.Commands.Utilities;
5+
using System.Management.Automation;
76

87
namespace PnP.PowerShell.Commands.Planner
98
{
109
[Cmdlet(VerbsCommon.Get, "PnPPlannerPlan")]
1110
[RequiredMinimalApiPermissions("Group.Read.All")]
1211
public class GetPlannerPlan : PnPGraphCmdlet
1312
{
14-
[Parameter(Mandatory = true)]
13+
private const string ParameterName_BYGROUP = "By Group";
14+
private const string ParameterName_BYPLANID = "By Plan Id";
15+
16+
[Parameter(Mandatory = true, HelpMessage = "Specify the group id of group owning the plan.", ParameterSetName = ParameterName_BYGROUP)]
1517
public PlannerGroupPipeBind Group;
1618

17-
[Parameter(Mandatory = false)]
19+
[Parameter(Mandatory = false, HelpMessage = "Specify the name of the plan.", ParameterSetName = ParameterName_BYGROUP)]
1820
public PlannerPlanPipeBind Identity;
1921

22+
[Parameter(Mandatory = true, HelpMessage = "Specify the ID of the plan.", ParameterSetName = ParameterName_BYPLANID)]
23+
public string Id;
2024

2125
[Parameter(Mandatory = false)]
2226
public SwitchParameter ResolveIdentities;
27+
2328
protected override void ExecuteCmdlet()
2429
{
25-
var groupId = Group.GetGroupId(HttpClient, AccessToken);
26-
if (groupId != null)
30+
if (ParameterSetName == ParameterName_BYGROUP)
2731
{
28-
if (ParameterSpecified(nameof(Identity)))
32+
var groupId = Group.GetGroupId(HttpClient, AccessToken);
33+
if (groupId != null)
2934
{
30-
WriteObject(Identity.GetPlanAsync(HttpClient, AccessToken, groupId, ResolveIdentities).GetAwaiter().GetResult());
35+
if (ParameterSpecified(nameof(Identity)))
36+
{
37+
WriteObject(Identity.GetPlanAsync(HttpClient, AccessToken, groupId, ResolveIdentities).GetAwaiter().GetResult());
38+
}
39+
else
40+
{
41+
WriteObject(PlannerUtility.GetPlansAsync(HttpClient, AccessToken, groupId, ResolveIdentities).GetAwaiter().GetResult(), true);
42+
}
3143
}
3244
else
3345
{
34-
WriteObject(PlannerUtility.GetPlansAsync(HttpClient, AccessToken, groupId, ResolveIdentities).GetAwaiter().GetResult(), true);
46+
throw new PSArgumentException("Group not found");
3547
}
3648
}
3749
else
3850
{
39-
throw new PSArgumentException("Group not found");
51+
WriteObject(PlannerUtility.GetPlanAsync(HttpClient, AccessToken, Id, ResolveIdentities).GetAwaiter().GetResult());
4052
}
4153
}
4254
}

0 commit comments

Comments
 (0)