Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[New Parameters to Existing Commandlet] - Added new parameters to Like and Unlike the page #3788

Merged
merged 8 commits into from
Mar 1, 2024
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;
NishkalankBezawada marked this conversation as resolved.
Show resolved Hide resolved

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
Loading