Skip to content

Commit 56775c8

Browse files
NishkalankBezawadaKoenZomersgautamdsheth
authored
[New Parameters to Existing Commandlet] - Added new parameters to Like and Unlike the page (#3788)
* Added new parameters to Like and Unlike the page * Resolving changes by gautam sheth. --------- Co-authored-by: Koen Zomers <koen@zomers.eu> Co-authored-by: Gautam Sheth <gautamdsheth@outlook.com>
1 parent bf9bc72 commit 56775c8

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed

documentation/Set-PnPPage.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,18 @@ Set-PnPPage -Identity "MyPage" -ShowPublishDate $true -Publish
105105
```
106106
Display the date when the page was published in the header section of the page
107107

108+
### EXAMPLE 12
109+
```powershell
110+
Set-PnPPage -Identity "MyPage.aspx" -Like
111+
```
112+
Likes the page
113+
114+
### EXAMPLE 11
115+
```powershell
116+
Set-PnPPage -Identity "MyPage.aspx" -Like:$false
117+
```
118+
Unlikes the page
119+
108120
## PARAMETERS
109121

110122
### -CommentsEnabled
@@ -363,6 +375,22 @@ Accept pipeline input: False
363375
Accept wildcard characters: False
364376
```
365377
378+
### -Like
379+
Likes the page, if parameter is set to false then it Unlikes the page
380+
381+
```yaml
382+
Type: SwitchParameter
383+
Parameter Sets: (All)
384+
385+
Required: False
386+
Position: Named
387+
Default value: None
388+
Accept pipeline input: False
389+
Accept wildcard characters: False
390+
```
391+
392+
393+
366394
## RELATED LINKS
367395
368396
[Microsoft 365 Patterns and Practices](https://aka.ms/m365pnp)

src/Commands/Pages/SetPage.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ public class SetPage : PnPWebCmdlet, IDynamicParameters
6464
[Parameter(Mandatory = false)]
6565
public bool ShowPublishDate;
6666

67+
[Parameter(Mandatory = false)]
68+
public SwitchParameter Like = false;
69+
70+
6771
private CustomHeaderDynamicParameters customHeaderParameters;
6872

6973
public object GetDynamicParameters()
@@ -174,6 +178,18 @@ protected override void ExecuteCmdlet()
174178
}
175179
}
176180

181+
if (ParameterSpecified(nameof(Like)))
182+
{
183+
if (Like)
184+
{
185+
clientSidePage.Like();
186+
}
187+
else
188+
{
189+
clientSidePage.Unlike();
190+
}
191+
}
192+
177193
if (ContentType != null)
178194
{
179195
string ctId = ContentType.GetIdOrWarn(this, CurrentWeb);

0 commit comments

Comments
 (0)