diff --git a/CHANGELOG.md b/CHANGELOG.md index 541510c8b..0822154ee 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -48,7 +48,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/). - Added `-ListPermissionScopes` parameter on `Get-PnPAccessToken` cmdlet to list the current permission scopes on the current access token. - Added `Get-PnPCopilotAgent` cmdlet that returns the Microsoft Copilot Agents in a site collection. - Added `Get-PnPFileRetentionLabel` cmdlet to fetch the file retention labels. [#4603](https://github.com/pnp/powershell/pull/4603) -- Added `Get/Set/Remove-PnPUserProfilePhoto` cmdlet to download, upload or remove the profile photo of the specified user. +- Added `Get/Set/Remove-PnPUserProfilePhoto` cmdlets to download, upload or remove the profile photo of the specified user. +- Added `New/Get/Remove/Update-PnPTodoList` cmdlets to manage Todo lists. ### Changed diff --git a/documentation/Get-PnPTodoList.md b/documentation/Get-PnPTodoList.md new file mode 100644 index 000000000..65f2e62f0 --- /dev/null +++ b/documentation/Get-PnPTodoList.md @@ -0,0 +1,106 @@ +--- +Module Name: PnP.PowerShell +title: Get-PnPTodoList +schema: 2.0.0 +applicable: SharePoint Online +external help file: PnP.PowerShell.dll-Help.xml +online version: https://pnp.github.io/powershell/cmdlets/Get-PnPTodoList.html +--- + +# Get-PnPTodoList + +## SYNOPSIS + +**Required Permissions** + + * Microsoft Graph API : One of Tasks.Read, Tasks.ReadWrite, Tasks.Read.All + +Gets one Todo list or all Todo lists. + +## SYNTAX + +```powershell +Get-PnPTodoList [[-Identity] ] [-[User] ] +``` + +## DESCRIPTION +Use the cmdlet to retrieve all Todo lists or a specific Todo list. + +## EXAMPLES + +### EXAMPLE 1 +```powershell +Get-PnPTodoList +``` + +This will return all your (logged-in user) todo lists. + +### EXAMPLE 2 +```powershell +Get-PnPTodoList -Identity "AAMkAGU4MGE1OTRiLTUzMGEtNDRjZi05ZmVmLWFiMTkyYmQxODRjOQAuAAAAAACQV8RStyZCQJ4ydzjIK5HmAQD2LFcxdwYMRqbupn47nEYYAASUnLfyAAA=" +``` + +This will return your (logged-in user) todo list with the specified Id. + +### EXAMPLE 3 +```powershell +Get-PnPTodoList -User john@doe.com +``` + +This will return the todo lists for the user john. + +### EXAMPLE 4 +```powershell +Get-PnPTodoList -User john@doe.com -Identity "AAMkAGU4MGE1OTRiLTUzMGEtNDRjZi05ZmVmLWFiMTkyYmQxODRjOQAuAAAAAACQV8RStyZCQJ4ydzjIK5HmAQD2LFcxdwYMRqbupn47nEYYAASUnLfyAAA=" +``` + +This will return the todo list for the user john with specified Id. + +## PARAMETERS + +### -Identity +Id of the Todo list. + +```yaml +Type: String +Parameter Sets: (All) + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -User +The UPN, Id or instance of an Azure AD user for which you would like to retrieve the todo list available to this user + +```yaml +Type: AzureADUserPipeBind +Parameter Sets: (All) + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Connection +Optional connection to be used by the cmdlet. Retrieve the value for this parameter by either specifying -ReturnConnection on Connect-PnPOnline or by executing Get-PnPConnection. + +```yaml +Type: PnPConnection +Parameter Sets: (All) + +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) + diff --git a/documentation/New-PnPTodoList.md b/documentation/New-PnPTodoList.md new file mode 100644 index 000000000..74f6b4c2c --- /dev/null +++ b/documentation/New-PnPTodoList.md @@ -0,0 +1,92 @@ +--- +Module Name: PnP.PowerShell +title: New-PnPTodoList +schema: 2.0.0 +applicable: SharePoint Online +external help file: PnP.PowerShell.dll-Help.xml +online version: https://pnp.github.io/powershell/cmdlets/New-PnPTodoList.html +--- + +# New-PnPTodoList + +## SYNOPSIS + +**Required Permissions** + + * Microsoft Graph API : One of Tasks.ReadWrite, Tasks.ReadWrite.All + +Creates a new todo list. + +## SYNTAX + +```powershell +New-PnPTodoList [[-DisplayName] ] [-[User] ] +``` + +## DESCRIPTION +Use the cmdlet to create a Todo list. + +## EXAMPLES + +### EXAMPLE 1 +```powershell +New-PnPTodoList -DisplayName "Travel items" +``` + +This will create a todo list associated with your (logged-in user) account. + +### EXAMPLE 2 +```powershell +New-PnPTodoList -User john@doe.com -DisplayName "Travel Items" +``` + +This will create a todo list associated with John's account. + +## PARAMETERS + +### -DisplayName +Display name of the Todo list. + +```yaml +Type: String +Parameter Sets: (All) + +Required: True +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -User +The UPN, Id or instance of an Azure AD user for which you would like to create the todo list. + +```yaml +Type: AzureADUserPipeBind +Parameter Sets: (All) + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Connection +Optional connection to be used by the cmdlet. Retrieve the value for this parameter by either specifying -ReturnConnection on Connect-PnPOnline or by executing Get-PnPConnection. + +```yaml +Type: PnPConnection +Parameter Sets: (All) + +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) + diff --git a/documentation/Remove-PnPTodoList.md b/documentation/Remove-PnPTodoList.md new file mode 100644 index 000000000..f726db7dd --- /dev/null +++ b/documentation/Remove-PnPTodoList.md @@ -0,0 +1,92 @@ +--- +Module Name: PnP.PowerShell +title: Remove-PnPTodoList +schema: 2.0.0 +applicable: SharePoint Online +external help file: PnP.PowerShell.dll-Help.xml +online version: https://pnp.github.io/powershell/cmdlets/Remove-PnPTodoList.html +--- + +# Remove-PnPTodoList + +## SYNOPSIS + +**Required Permissions** + + * Microsoft Graph API : Tasks.ReadWrite + +Removes a new todo list. + +## SYNTAX + +```powershell +Remove-PnPTodoList [[-Identity] ] [-[User] ] +``` + +## DESCRIPTION +Use the cmdlet to delete a Todo list. + +## EXAMPLES + +### EXAMPLE 1 +```powershell +Remove-PnPTodoList -Identity "AAMkAGU4MGE1OTRiLTUzMGEtNDRjZi05ZmVmLWFiMTkyYmQxODRjOQAuAAAAAACQV8RStyZCQJ4ydzjIK5HmAQD2LFcxdwYMRqbupn47nEYYAASYG0vWAAA=" +``` + +This will delete a todo list with specified Id associated with your (logged-in user) account. + +### EXAMPLE 2 +```powershell +Remove-PnPTodoList -Identity "AAMkAGU4MGE1OTRiLTUzMGEtNDRjZi05ZmVmLWFiMTkyYmQxODRjOQAuAAAAAACQV8RStyZCQJ4ydzjIK5HmAQD2LFcxdwYMRqbupn47nEYYAASYG0vWAAA=" -User john@doe.com +``` + +This will delete a todo list with specified Id associated with John's account. + +## PARAMETERS + +### -Identity +Id of the Todo list. + +```yaml +Type: String +Parameter Sets: (All) + +Required: True +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -User +The UPN, Id or instance of an Azure AD user for which you would like to create the todo list. + +```yaml +Type: AzureADUserPipeBind +Parameter Sets: (All) + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Connection +Optional connection to be used by the cmdlet. Retrieve the value for this parameter by either specifying -ReturnConnection on Connect-PnPOnline or by executing Get-PnPConnection. + +```yaml +Type: PnPConnection +Parameter Sets: (All) + +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) + diff --git a/documentation/Update-PnPTodoList.md b/documentation/Update-PnPTodoList.md new file mode 100644 index 000000000..9eee915a2 --- /dev/null +++ b/documentation/Update-PnPTodoList.md @@ -0,0 +1,106 @@ +--- +Module Name: PnP.PowerShell +title: Update-PnPTodoList +schema: 2.0.0 +applicable: SharePoint Online +external help file: PnP.PowerShell.dll-Help.xml +online version: https://pnp.github.io/powershell/cmdlets/Update-PnPTodoList.html +--- + +# Update-PnPTodoList + +## SYNOPSIS + +**Required Permissions** + + * Microsoft Graph API : Tasks.ReadWrite + +Updates a new todo list. + +## SYNTAX + +```powershell +Update-PnPTodoList [[-Identity] ] [[-DisplayName] ] [-[User] ] +``` + +## DESCRIPTION +Use the cmdlet to update display name of a Todo list. + +## EXAMPLES + +### EXAMPLE 1 +```powershell +Update-PnPTodoList -Identity "AAMkAGU4MGE1OTRiLTUzMGEtNDRjZi05ZmVmLWFiMTkyYmQxODRjOQAuAAAAAACQV8RStyZCQJ4ydzjIK5HmAQD2LFcxdwYMRqbupn47nEYYAASYG0vWAAA=" -DisplayName "Travel items" +``` + +This will update a todo list's display name associated with your (logged-in user) account. + +### EXAMPLE 2 +```powershell +Update-PnPTodoList -Identity "AAMkAGU4MGE1OTRiLTUzMGEtNDRjZi05ZmVmLWFiMTkyYmQxODRjOQAuAAAAAACQV8RStyZCQJ4ydzjIK5HmAQD2LFcxdwYMRqbupn47nEYYAASYG0vWAAA=" -User john@doe.com -DisplayName "Travel Items" +``` + +This will update the display name of a todo list associated with John's account. + +## PARAMETERS + +### -Identity +Id of the Todo list. + +```yaml +Type: String +Parameter Sets: (All) + +Required: True +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -DisplayName +Display name of the Todo list. + +```yaml +Type: String +Parameter Sets: (All) + +Required: True +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -User +The UPN, Id or instance of an Azure AD user for which you would like to create the todo list. + +```yaml +Type: AzureADUserPipeBind +Parameter Sets: (All) + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Connection +Optional connection to be used by the cmdlet. Retrieve the value for this parameter by either specifying -ReturnConnection on Connect-PnPOnline or by executing Get-PnPConnection. + +```yaml +Type: PnPConnection +Parameter Sets: (All) + +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) + diff --git a/src/Commands/Model/ToDo/ToDo.cs b/src/Commands/Model/ToDo/ToDo.cs new file mode 100644 index 000000000..6fe344922 --- /dev/null +++ b/src/Commands/Model/ToDo/ToDo.cs @@ -0,0 +1,46 @@ +using System.Text.Json.Serialization; + +namespace PnP.PowerShell.Commands.Model.ToDo +{ + public class ToDoList + { + /// + /// Unique identifier of the Todo task list + /// + [JsonPropertyName("id")] + public string Id { get; set; } + + /// + /// Name of the Todo task list + /// + [JsonPropertyName("displayName")] + public string DisplayName { get; set; } + + /// + /// True if the user is owner of the given task list. + /// + [JsonPropertyName("isOwner")] + public bool IsOwner { get; set; } + + /// + /// True if the task list is shared with other users + /// + [JsonPropertyName("isShared")] + public bool IsShared { get; set; } + + /// + /// True if the task list is shared with other users + /// + [JsonConverter(typeof(JsonStringEnumConverter))] + [JsonPropertyName("wellknownListName")] + public WellknownListName WellknownListName { get; set; } + } + + public enum WellknownListName + { + None, + DefaultList, + FlaggedEmails, + UnknownFutureValue + } +} diff --git a/src/Commands/Model/VivaEngage/VivaEngageCommunity.cs b/src/Commands/Model/VivaEngage/VivaEngageCommunity.cs index c2b90fd7d..71d827f11 100644 --- a/src/Commands/Model/VivaEngage/VivaEngageCommunity.cs +++ b/src/Commands/Model/VivaEngage/VivaEngageCommunity.cs @@ -27,6 +27,7 @@ public class VivaEngageCommunity /// Privacy setting of the Viva Engage community /// [JsonPropertyName("privacy")] + [JsonConverter(typeof(JsonStringEnumConverter))] public CommunityPrivacy Privacy { get; set; } /// diff --git a/src/Commands/Purview/GetAvailableSensitivityLabel.cs b/src/Commands/Purview/GetAvailableSensitivityLabel.cs index 0b3dde439..d63aa0e32 100644 --- a/src/Commands/Purview/GetAvailableSensitivityLabel.cs +++ b/src/Commands/Purview/GetAvailableSensitivityLabel.cs @@ -33,7 +33,7 @@ protected override void ExecuteCmdlet() return; } - url = $"/beta/users/{user.UserPrincipalName}/security/informationProtection/sensitivityLabels"; + url = $"/beta/users/{user.Id.Value}/security/informationProtection/sensitivityLabels"; } else { diff --git a/src/Commands/ToDo/GetTodoList.cs b/src/Commands/ToDo/GetTodoList.cs new file mode 100644 index 000000000..cfc8aea21 --- /dev/null +++ b/src/Commands/ToDo/GetTodoList.cs @@ -0,0 +1,55 @@ +using PnP.PowerShell.Commands.Attributes; +using PnP.PowerShell.Commands.Base; +using PnP.PowerShell.Commands.Base.PipeBinds; +using System.Management.Automation; + +namespace PnP.PowerShell.Commands.ToDo +{ + [Cmdlet(VerbsCommon.Get, "PnPTodoList")] + [RequiredApiDelegatedOrApplicationPermissions("graph/Tasks.Read")] + [RequiredApiDelegatedOrApplicationPermissions("graph/Tasks.ReadWrite")] + [RequiredApiApplicationPermissions("graph/Tasks.Read.All")] + public class GetTodoList : PnPGraphCmdlet + { + [Parameter(Mandatory = false)] + public string Identity; + + [Parameter(Mandatory = false)] + public AzureADUserPipeBind User; + protected override void ExecuteCmdlet() + { + string url = "/v1.0/me/todo/lists"; + + if (Connection.ConnectionMethod == Model.ConnectionMethod.AzureADAppOnly) + { + if (!ParameterSpecified(nameof(User))) + { + throw new PSInvalidOperationException($"Please specify the parameter {nameof(User)} when invoking this cmdlet in app-only scenario"); + } + } + + if (ParameterSpecified(nameof(User))) + { + var user = User.GetUser(AccessToken, Connection.AzureEnvironment); + if (user == null) + { + WriteWarning("Provided user not found"); + return; + } + url = $"/v1.0/users/{user.Id}/todo/lists"; + } + if (ParameterSpecified(nameof(Identity))) + { + url += $"/{Identity}"; + + var todoList = RequestHelper.Get(url); + WriteObject(todoList, false); + } + else + { + var todoLists = RequestHelper.GetResultCollection(url); + WriteObject(todoLists, true); + } + } + } +} diff --git a/src/Commands/ToDo/NewTodoList.cs b/src/Commands/ToDo/NewTodoList.cs new file mode 100644 index 000000000..e56fbd8bd --- /dev/null +++ b/src/Commands/ToDo/NewTodoList.cs @@ -0,0 +1,49 @@ +using PnP.PowerShell.Commands.Attributes; +using PnP.PowerShell.Commands.Base; +using PnP.PowerShell.Commands.Base.PipeBinds; +using System.Management.Automation; +using System.Net.Http; + +namespace PnP.PowerShell.Commands.ToDo +{ + [Cmdlet(VerbsCommon.New, "PnPTodoList")] + [RequiredApiDelegatedOrApplicationPermissions("graph/Tasks.ReadWrite")] + [RequiredApiApplicationPermissions("graph/Tasks.ReadWrite.All")] + public class NewTodoList : PnPGraphCmdlet + { + [Parameter(Mandatory = true)] + public string DisplayName; + + [Parameter(Mandatory = false)] + public AzureADUserPipeBind User; + protected override void ExecuteCmdlet() + { + string url = "/v1.0/me/todo/lists"; + + if (Connection.ConnectionMethod == Model.ConnectionMethod.AzureADAppOnly) + { + if (!ParameterSpecified(nameof(User))) + { + throw new PSInvalidOperationException($"Please specify the parameter {nameof(User)} when invoking this cmdlet in app-only scenario"); + } + } + + if (ParameterSpecified(nameof(User))) + { + var user = User.GetUser(AccessToken, Connection.AzureEnvironment); + if (user == null) + { + WriteWarning("Provided user not found"); + return; + } + url = $"/v1.0/users/{user.Id}/todo/lists"; + } + + var stringContent = new StringContent($"{{'displayName':'{DisplayName}'}}"); + stringContent.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/json"); + + var todoList = RequestHelper.Post(url, stringContent); + WriteObject(todoList, false); + } + } +} diff --git a/src/Commands/ToDo/RemoveTodoList.cs b/src/Commands/ToDo/RemoveTodoList.cs new file mode 100644 index 000000000..919c7ac85 --- /dev/null +++ b/src/Commands/ToDo/RemoveTodoList.cs @@ -0,0 +1,46 @@ +using PnP.PowerShell.Commands.Attributes; +using PnP.PowerShell.Commands.Base; +using PnP.PowerShell.Commands.Base.PipeBinds; +using System.Management.Automation; + +namespace PnP.PowerShell.Commands.ToDo +{ + [Cmdlet(VerbsCommon.Remove, "PnPTodoList")] + [RequiredApiDelegatedOrApplicationPermissions("graph/Tasks.ReadWrite")] + [ApiNotAvailableUnderApplicationPermissions] + public class RemoveTodoList : PnPGraphCmdlet + { + [Parameter(Mandatory = true)] + public string Identity; + + [Parameter(Mandatory = false)] + public AzureADUserPipeBind User; + + protected override void ExecuteCmdlet() + { + string url = $"/v1.0/me/todo/lists/{Identity}"; + + if (ParameterSpecified(nameof(User))) + { + var user = User.GetUser(AccessToken, Connection.AzureEnvironment); + if (user == null) + { + WriteWarning("Provided user not found"); + return; + } + url = $"/v1.0/users/{user.Id}/todo/lists/{Identity}"; + } + + var graphResult = RequestHelper.Delete(url); + + if (graphResult.StatusCode == System.Net.HttpStatusCode.NoContent) + { + WriteVerbose("Todo list deleted successfully"); + } + else + { + throw new PSArgumentException("Todo list could not be deleted", nameof(Identity)); + } + } + } +} diff --git a/src/Commands/ToDo/UpdateTodoList.cs b/src/Commands/ToDo/UpdateTodoList.cs new file mode 100644 index 000000000..ce1ec9b06 --- /dev/null +++ b/src/Commands/ToDo/UpdateTodoList.cs @@ -0,0 +1,45 @@ +using PnP.PowerShell.Commands.Attributes; +using PnP.PowerShell.Commands.Base; +using PnP.PowerShell.Commands.Base.PipeBinds; +using System.Management.Automation; +using System.Net.Http; + +namespace PnP.PowerShell.Commands.ToDo +{ + [Cmdlet(VerbsData.Update, "PnPTodoList")] + [RequiredApiDelegatedOrApplicationPermissions("graph/Tasks.ReadWrite")] + [ApiNotAvailableUnderApplicationPermissions] + public class UpdateTodoList : PnPGraphCmdlet + { + [Parameter(Mandatory = true)] + public string Identity; + + [Parameter(Mandatory = true)] + public string DisplayName; + + [Parameter(Mandatory = false)] + public AzureADUserPipeBind User; + + protected override void ExecuteCmdlet() + { + string url = $"/v1.0/me/todo/lists/{Identity}"; + + if (ParameterSpecified(nameof(User))) + { + var user = User.GetUser(AccessToken, Connection.AzureEnvironment); + if (user == null) + { + WriteWarning("Provided user not found"); + return; + } + url = $"/v1.0/users/{user.Id}/todo/lists/{Identity}"; + } + + var stringContent = new StringContent($"{{'displayName':'{DisplayName}'}}"); + stringContent.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/json"); + + var todoList = RequestHelper.Patch(url, stringContent); + WriteObject(todoList, false); + } + } +}