Skip to content

Commit

Permalink
Added new parameters to Like and Unlike the page
Browse files Browse the repository at this point in the history
  • Loading branch information
NishkalankBezawada committed Feb 24, 2024
1 parent 329b403 commit f1c1448
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 0 deletions.
40 changes: 40 additions & 0 deletions documentation/Set-PnPPage.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
22 changes: 22 additions & 0 deletions src/Commands/Pages/SetPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit f1c1448

Please sign in to comment.