Skip to content
This repository was archived by the owner on Jan 19, 2021. It is now read-only.

Added GetPnPSiteHistoricalVersionsStatus #2832

Draft
wants to merge 4 commits into
base: dev
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -11,6 +11,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
- Updated `Get/Set-PnPSearchSettings` with an option `-SearchBoxPlaceholderText` to set search placeholder text for the SPO nav bar search box
- Added Set-PnPTermGroup cmdlet to update an existing taxonomy term group.
- Added Set-PnPTeamifyPromptHidden to hide the teamify prompt on a group connected Team Site (modern team site)
- Added Get-PnPSiteHistoricalVersionsStatus to get information about the Historical Versions feature, a feature that makes past versions of documents searchable for eDiscovery when enabled

### Changed
- Changed the client id of the application used behind the scenes when authenticating to a tenant where Legacy Authentication has been turned off. We now by default utilize the PnP Management Shell application. If you have not provided consent you will be prompted with a message on how to provide consent.
1 change: 1 addition & 0 deletions Commands/PnP.PowerShell.Commands.csproj
Original file line number Diff line number Diff line change
@@ -806,6 +806,7 @@
<Compile Include="RecordsManagement\SetListRecordDeclaration.cs" />
<Compile Include="Search\GetSearchCrawlLog.cs" />
<Compile Include="Search\GetSearchSettings.cs" />
<Compile Include="Search\GetSiteHistoricalVersionsStatus.cs" />
<Compile Include="Search\SetSearchSettings.cs" />
<Compile Include="Enums\SearchSettingsScope.cs" />
<Compile Include="SiteDesigns\GetSiteDesignTask.cs" />
56 changes: 56 additions & 0 deletions Commands/Search/GetSiteHistoricalVersionsStatus.cs
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
{
Copy link
Contributor

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?

Copy link
Collaborator

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.

Copy link
Contributor

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?


protected override void ExecuteCmdlet()
{
var siteLog = new SiteCrawlLog(ClientContext, ClientContext.Site);
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