Skip to content

Instantly share code, notes, and snippets.

using Microsoft.SharePoint.Client;
using Microsoft.SharePoint.Client.Utilities;
using System.Collections.Generic;
public static class Email
{
public static void Send(ClientContext ctx, string[] to, string subject, string body, bool html = false)
{
var properties = new EmailProperties();
properties.To = to;
Array.prototype.slice.call(document.querySelectorAll("#onetidMngCytpeRptrTable a")).forEach(function(a) { a.setAttribute("href", "\u002fsites\u002fcontentTypeHub/_layouts/15/ManageContentType.aspx?ctype=" + a.getAttribute("id").replace("LinkEditType", "")); });
@zplume
zplume / GetUsers.js
Last active August 24, 2017 09:22
Quick script to get SharePoint user properties (LoginName, Title, Email) for multiple users, via the Chrome console, using async/await, Promise.all, fetch, computed properties and rest parameters.
(async function() {
let userIds = [239, 405];
// computed property name: [prop]:
// rest parameters: ...props
// stolen from: https://stackoverflow.com/a/25554551
function pick(o, ...props) {
return Object.assign({}, ...props.map(prop => ({[prop]: o[prop]})));
}
Param(
[Parameter(Mandatory=$True)]
$AppPrincipalId,
[Parameter(Mandatory=$True)]
$TenantId,
[string]$ClientSecret
)
function getQueryStringParam(searchKey) {
// get URI object
var uri = new URI(location.href);
// get query params
var queryParams = uri.getQueryAsObject();
// get queryParam keys
var queryParamKeys = Object.keys(queryParams);
@zplume
zplume / Log.ts
Last active December 12, 2017 13:55
export default class Log {
private prefix: string;
private logSource: object;
private parseArgument(arg: any): string {
return typeof(arg) === "string" ? arg : JSON.stringify(arg);
}
private getMethodName(callingFunction: Function): string {
const methodNames = Object.getOwnPropertyNames(Object.getPrototypeOf(this.logSource));
using Microsoft.SharePoint.Client;
using System;
using System.Net;
using System.Threading;
using System.Threading.Tasks;
using static Microsoft.SharePoint.Client.ClientContextExtensions;
public static class ClientContextExtensions
{
public static async Task ExecuteQueryRetryAsync(this ClientContext clientContext,
public static class AuthCheck
{
// This Function will return OK if the user is authenticated
[FunctionName("AuthCheck")]
public static HttpResponseMessage Run([HttpTrigger(AuthorizationLevel.Anonymous, "get")]HttpRequestMessage request, TraceWriter log)
{
var response = request.CreateResponse(HttpStatusCode.OK);
Cors.Enable(request, response);
Remove-Item d:\home\site\wwwroot\* -recurse
$tenantUrl = "https://yourtenant.sharepoint.com"
$credentials = Get-Credential
Connect-PnPOnline -Url $tenantUrl -Credentials $credentials
$sites = Get-PnPSiteSearchQueryResults -All
Disconnect-PnPOnline
$script:wfStatuses = @()
function Get-WebWorkflowData($web) {