Skip to content

Commit

Permalink
Added -OutputTask parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
erwinvanhunen committed Sep 4, 2024
1 parent 02664d4 commit 113a936
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).

### Changed

- Added `-OutputTask` switch to `Add-PnPPlannerTask` cmdlet which will return the just created task so inspect its ID, ETag, etc. values.
- Improved `Invoke-PnPGraphMethod` cmdlet now to also support a hashtable value for the AdditionalHeaders parameter besides the current Dictionary<string,string>. See documentation.
- Improved managed identity authentication for connecting to different M365 services.
- Improved error message for `Export-PnPPage` cmdlet when the page doesn't exist.
Expand Down
25 changes: 23 additions & 2 deletions documentation/Add-PnPPlannerTask.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ Adds a new task to a planner bucket
```powershell
Add-PnPPlannerTask -Group <PlannerGroupPipeBind> -Plan <PlannerPlanPipeBind> -Bucket <PlannerBucketPipeBind> -Title <String>
[-PercentComplete <Int32>] [-DueDateTime <DateTime>] [-StartDateTime <DateTime>]
[-AssignedTo <String[]] [-Priority <Int32>] [-Description <String>]
[-AssignedTo <String[]] [-Priority <Int32>] [-Description <String>] [-OutputTask]
```

### By Plan Id
```powershell
Add-PnPPlannerTask -Bucket <PlannerBucketPipeBind> -PlanId <String> -Title <String>
[-PercentComplete <Int32>] [-DueDateTime <DateTime>] [-StartDateTime <DateTime>]
[-AssignedTo <String[]] [-Priority <Int32>] [-Description <String>]
[-AssignedTo <String[]] [-Priority <Int32>] [-Description <String>] [-OutputTask]
```

Expand Down Expand Up @@ -61,6 +61,12 @@ Add-PnPPlannerTask -Group "Marketing" -Plan "Conference Plan" -Bucket "Todos" -T

This cmdlet adds a new task and assigns to [email protected] and [email protected]

### Example 4
```powershell
$task = Add-PnPPlannerTask -Group "Marketing" -Plan "Conference Plan" -Bucket "Todos" -Title "Design booth layout" -AssignedTo "[email protected]","[email protected]" -OutputTask
```

This returns the task as an object to inspect specific values

## PARAMETERS

Expand Down Expand Up @@ -233,6 +239,21 @@ Accept pipeline input: False
Accept wildcard characters: False
```
### -OutputTask
Returns the just created task as an object to inspect values
```yaml
Type: SwitchParameter
Parameter Sets: (All)

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
Expand Down
9 changes: 9 additions & 0 deletions src/Commands/Planner/AddPlannerTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ public class AddPlannerTask : PnPGraphCmdlet
[Parameter(Mandatory = false, ParameterSetName = ParameterAttribute.AllParameterSets)]
public string[] AssignedTo;

[Parameter(Mandatory = false, ParameterSetName = ParameterAttribute.AllParameterSets)]
public SwitchParameter OutputTask;

protected override void ExecuteCmdlet()
{
PlannerTask createdTask;
Expand Down Expand Up @@ -146,6 +149,12 @@ protected override void ExecuteCmdlet()
{
var existingTaskDetails = PlannerUtility.GetTaskDetails(this, Connection, AccessToken, createdTask.Id, false);
PlannerUtility.UpdateTaskDetails(this, Connection, AccessToken, existingTaskDetails, Description);
createdTask.HasDescription = true;
}

if(OutputTask.IsPresent)
{
WriteObject(createdTask);
}
}
}
Expand Down

0 comments on commit 113a936

Please sign in to comment.