-
Notifications
You must be signed in to change notification settings - Fork 358
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added new cmdlet to return modern page scheduling enabled status
- Loading branch information
1 parent
3db83bc
commit 4ac757f
Showing
2 changed files
with
87 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
--- | ||
Module Name: PnP.PowerShell | ||
schema: 2.0.0 | ||
applicable: SharePoint Online | ||
online version: https://pnp.github.io/powershell/cmdlets/Get-PnPPageSchedulingEnabled.html | ||
external help file: PnP.PowerShell.dll-Help.xml | ||
title: Get-PnPPageSchedulingEnabled | ||
--- | ||
|
||
# Get-PnPPageSchedulingEnabled | ||
|
||
## SYNOPSIS | ||
|
||
Return true of false, reflecting the state of the modern page schedule feature | ||
|
||
## SYNTAX | ||
|
||
```powershell | ||
Get-PnPPageSchedulingEnabled [-Connection <PnPConnection>] | ||
``` | ||
|
||
## DESCRIPTION | ||
|
||
This will return a boolean value stating if the modern page schedule feature has been enabled or not. | ||
|
||
## EXAMPLES | ||
|
||
### EXAMPLE 1 | ||
```powershell | ||
Get-PnPPageSchedulingEnabled | ||
``` | ||
|
||
This will return a boolean value stating if the modern page schedule feature has been enabled or not. | ||
|
||
## PARAMETERS | ||
|
||
### -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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
using System.Management.Automation; | ||
using System.Text.Json; | ||
using PnP.PowerShell.Commands.Utilities; | ||
|
||
namespace PnP.PowerShell.Commands.Pages | ||
{ | ||
[Cmdlet(VerbsCommon.Get, "PnPPageSchedulingEnabled")] | ||
[OutputType(typeof(void))] | ||
public class GetPageSchedulingEnabled : PnPWebCmdlet | ||
{ | ||
protected override void ExecuteCmdlet() | ||
{ | ||
var pagesList = PagesUtility.GetModernPagesLibrary(PnPContext.Web); | ||
var payload = new | ||
{ | ||
parameters = new | ||
{ | ||
AddRequiredFields = false, | ||
RenderOptions = 16385 | ||
} | ||
}; | ||
|
||
var results = Utilities.REST.RestHelper.PostAsync<JsonElement>(Connection.HttpClient, $"{PnPContext.Web.Url}/_api/web/lists(guid'{pagesList.Id}')/RenderListDataAsStream", ClientContext, payload, false).GetAwaiter().GetResult(); | ||
|
||
var frameworkClientInfo = results.GetProperty("SPFrameworkClientInfo"); | ||
var pageContextJson = frameworkClientInfo.GetProperty("PageContextJson"); | ||
var value = pageContextJson.GetString(); | ||
var contextElement = JsonDocument.Parse(value); | ||
var pageContextInfoElement = contextElement.RootElement.GetProperty("spPageContextInfo"); | ||
var listPageScheduling = pageContextInfoElement.GetProperty("listPageSchedulingEnabled").GetBoolean(); | ||
WriteObject(listPageScheduling); | ||
} | ||
} | ||
} |