Skip to content

Instantly share code, notes, and snippets.

@BurstX
BurstX / Get-SitePolicy.ps1
Created March 21, 2017 10:24
PowerShell script to check if a site policy exists in a specified list of SharePoint sites
<#
.SYNOPSIS
Tht script checks is a site policy exists in a site collection.
.DESCRIPTION
.PARAMETER SiteUrl
URL of a site collection to check the policy existence.
.PARAMETER PolicyName
Name of the policy to check.
#>
@BurstX
BurstX / OpenSite.ps1
Created January 19, 2017 12:54
PowerShell: open site which was closed and set as read-only via a site policy
$spWeb = Get-SPWeb $SiteUrl
# Check whether site is closed
$isClosed = [Microsoft.Office.RecordsManagement.InformationPolicy.ProjectPolicy]::IsProjectClosed($spWeb)
if($isClosed)
{
[Microsoft.Office.RecordsManagement.InformationPolicy.ProjectPolicy]::OpenProject($spWeb)
}
@BurstX
BurstX / SearchQuery.cs
Last active May 10, 2016 08:18
Query search app
using (var ctx = new ClientContext(this.SiteCollectionUri)) // TEST root site collection URL
{
ctx.ExecutingWebRequest += (object sender, WebRequestEventArgs e) =>
{
// e.WebRequestExecutor.WebRequest.UserAgent = @"Mozilla/4.0 (compatible; MSIE 4.01; windows NT; MS Search 6.0 Robot)";
e.WebRequestExecutor.WebRequest.Headers.Add(@"X-FORMS_BASED_AUTH_ACCEPTED", @"f");
};
var query = new KeywordQuery(ctx);
query.QueryText = "WebTemplate:STS";