-
Notifications
You must be signed in to change notification settings - Fork 656
Added GetPnPSiteHistoricalVersionsStatus #2832
base: dev
Are you sure you want to change the base?
Changes from 3 commits
6c266dc
9a776b7
01996fb
534b490
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#if !ONPREMISES | ||
using System.Collections.Generic; | ||
using System.Management.Automation; | ||
using Microsoft.SharePoint.Client; | ||
using Microsoft.SharePoint.Client.Search.Administration; | ||
using PnP.PowerShell.CmdletHelpAttributes; | ||
|
||
namespace PnP.PowerShell.Commands.Search | ||
{ | ||
[Cmdlet(VerbsCommon.Get, "PnPSiteHistoricalVersionsStatus", DefaultParameterSetName = "Xml")] | ||
[CmdletHelp("Returns information about the Historical Versions feature for the current site collection from the context. " + | ||
wobba marked this conversation as resolved.
Show resolved
Hide resolved
|
||
"The document statistics are only updated periodically, check the next update time property (in UTC) to see when new data will be available.", | ||
SupportedPlatform = CmdletSupportedPlatform.Online, | ||
Category = CmdletHelpCategory.Search)] | ||
[CmdletExample( | ||
Code = @"PS:> Get-PnPSiteHistoricalVersionsStatus", | ||
Remarks = "Returns the status of the feature as well as the number of documents processed for the site if the feature is enabled.", | ||
SortOrder = 1)] | ||
public class GetSiteHistoricalVersionsStatus : PnPWebCmdlet | ||
{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @erwinvanhunen would it make sense to inherit from There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It probably would make more sense indeed. What's the current status of the availability of this API? Does anyone know? Still doesn't seem to compile here against the latest CSOM version. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We have no wait until the CSOM change is pushed. Don't have an ETA, but maybe @VesaJuvonen has track of this? |
||
|
||
protected override void ExecuteCmdlet() | ||
{ | ||
var siteLog = new SiteCrawlLog(ClientContext, ClientContext.Site); | ||
wobba marked this conversation as resolved.
Show resolved
Hide resolved
|
||
ClientContext.Load(siteLog); | ||
|
||
var resultTable = siteLog.GetHistoricalVersionsStatus(); | ||
ClientContext.ExecuteQueryRetry(); | ||
|
||
if (resultTable.Value == null || resultTable.Value.Rows.Count == 0) | ||
{ | ||
WriteWarning("No information was obtained for the current site"); | ||
} | ||
else | ||
{ | ||
// The API should only return 1 row | ||
WriteObject(ConvertToPSObject(resultTable.Value.Rows[0])); | ||
} | ||
|
||
} | ||
|
||
private object ConvertToPSObject(IDictionary<string, object> r) | ||
{ | ||
PSObject res = new PSObject(); | ||
if (r != null) | ||
{ | ||
foreach (var kvp in r) | ||
{ | ||
res.Properties.Add(new PSNoteProperty(kvp.Key, kvp.Value)); | ||
} | ||
} | ||
return res; | ||
} | ||
} | ||
} | ||
#endif |
Uh oh!
There was an error while loading. Please reload this page.