This repository was archived by the owner on Jan 19, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 661
Added GetPnPSiteHistoricalVersionsStatus #2832
Draft
ZhuoWeiLi
wants to merge
4
commits into
pnp:dev
Choose a base branch
from
ZhuoWeiLi:SiteHistoricalVersionsStatus
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+58
−0
Draft
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
6c266dc
Added command for getting the historical versions status of a site
9a776b7
Merge remote-tracking branch 'upstream/dev' into SiteHistoricalVersio…
01996fb
Fixed namespace
534b490
Updated documentation to be more descriptive about historical versions
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
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,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")] | ||
[CmdletHelp("Returns summary crawl info about the Historical Versions feature for the current site collection from the context. " + | ||
"This is a feature that makes past versions of documents searchable for eDiscovery when enabled.", | ||
SupportedPlatform = CmdletSupportedPlatform.Online, | ||
Category = CmdletHelpCategory.Search)] | ||
[CmdletExample( | ||
Code = @"PS:> Get-PnPSiteHistoricalVersionsStatus", | ||
Remarks = "Returns the count of documents with historical versions processed and the count of total documents with versions enabled on the site, as well as when these counts will be next updated (all times in UTC).", | ||
SortOrder = 1)] | ||
public class GetSiteHistoricalVersionsStatus : PnPWebCmdlet | ||
{ | ||
|
||
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 |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@erwinvanhunen would it make sense to inherit from
PnPAdminCmdlet
instead, and maybe move the cmdlet to the Admin folder instead of search?There was a problem hiding this comment.
Choose a reason for hiding this comment
The 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 comment
The 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?