From f1c1448e22ae7380597a7fecc146059773ff0043 Mon Sep 17 00:00:00 2001 From: Nishkalank Date: Sat, 24 Feb 2024 19:00:36 +0100 Subject: [PATCH 1/2] Added new parameters to Like and Unlike the page --- documentation/Set-PnPPage.md | 40 +++++++++++++++++++++++++++++++++++ src/Commands/Pages/SetPage.cs | 22 +++++++++++++++++++ 2 files changed, 62 insertions(+) diff --git a/documentation/Set-PnPPage.md b/documentation/Set-PnPPage.md index 046434d9b..8becb724b 100644 --- a/documentation/Set-PnPPage.md +++ b/documentation/Set-PnPPage.md @@ -105,6 +105,18 @@ Set-PnPPage -Identity "MyPage" -ShowPublishDate $true -Publish ``` Display the date when the page was published in the header section of the page +### EXAMPLE 12 +```powershell +Set-PnPPage -Identity "MyPage.aspx" -Like +``` +Likes the page + +### EXAMPLE 11 +```powershell +Set-PnPPage -Identity "MyPage.aspx" -UnLike +``` +Unlikes the page + ## PARAMETERS ### -CommentsEnabled @@ -363,6 +375,34 @@ Accept pipeline input: False Accept wildcard characters: False ``` +### -Like +Likes the page + +```yaml +Type: SwitchParameter +Parameter Sets: (All) + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -UnLike +Likes the page + +```yaml +Type: SwitchParameter +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) \ No newline at end of file diff --git a/src/Commands/Pages/SetPage.cs b/src/Commands/Pages/SetPage.cs index 5eee83bff..267ee31dd 100644 --- a/src/Commands/Pages/SetPage.cs +++ b/src/Commands/Pages/SetPage.cs @@ -64,6 +64,12 @@ public class SetPage : PnPWebCmdlet, IDynamicParameters [Parameter(Mandatory = false)] public bool ShowPublishDate; + [Parameter(Mandatory = false)] + public SwitchParameter Like = false; + + [Parameter(Mandatory = false)] + public SwitchParameter UnLike = false; + private CustomHeaderDynamicParameters customHeaderParameters; public object GetDynamicParameters() @@ -174,6 +180,22 @@ protected override void ExecuteCmdlet() } } + if (ParameterSpecified(nameof(Like))) + { + if (Like) + { + clientSidePage.Like(); + } + } + + if (ParameterSpecified(nameof(UnLike))) + { + if (UnLike) + { + clientSidePage.Unlike(); + } + } + if (ContentType != null) { string ctId = ContentType.GetIdOrWarn(this, CurrentWeb); From e20be9873422638adfdea628e1c5851f9990d6d1 Mon Sep 17 00:00:00 2001 From: Nishkalank Date: Thu, 29 Feb 2024 21:00:21 +0100 Subject: [PATCH 2/2] Resolving changes by gautam sheth. --- documentation/Set-PnPPage.md | 16 ++-------------- src/Commands/Pages/SetPage.cs | 10 ++-------- 2 files changed, 4 insertions(+), 22 deletions(-) diff --git a/documentation/Set-PnPPage.md b/documentation/Set-PnPPage.md index 8becb724b..1d189cd53 100644 --- a/documentation/Set-PnPPage.md +++ b/documentation/Set-PnPPage.md @@ -113,7 +113,7 @@ Likes the page ### EXAMPLE 11 ```powershell -Set-PnPPage -Identity "MyPage.aspx" -UnLike +Set-PnPPage -Identity "MyPage.aspx" -Like:$false ``` Unlikes the page @@ -376,7 +376,7 @@ Accept wildcard characters: False ``` ### -Like -Likes the page +Likes the page, if parameter is set to false then it Unlikes the page ```yaml Type: SwitchParameter @@ -389,19 +389,7 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -UnLike -Likes the page - -```yaml -Type: SwitchParameter -Parameter Sets: (All) -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` ## RELATED LINKS diff --git a/src/Commands/Pages/SetPage.cs b/src/Commands/Pages/SetPage.cs index 267ee31dd..4aa368965 100644 --- a/src/Commands/Pages/SetPage.cs +++ b/src/Commands/Pages/SetPage.cs @@ -67,8 +67,6 @@ public class SetPage : PnPWebCmdlet, IDynamicParameters [Parameter(Mandatory = false)] public SwitchParameter Like = false; - [Parameter(Mandatory = false)] - public SwitchParameter UnLike = false; private CustomHeaderDynamicParameters customHeaderParameters; @@ -185,12 +183,8 @@ protected override void ExecuteCmdlet() if (Like) { clientSidePage.Like(); - } - } - - if (ParameterSpecified(nameof(UnLike))) - { - if (UnLike) + } + else { clientSidePage.Unlike(); }