Skip to content

Instantly share code, notes, and snippets.

View phillipharding's full-sized avatar

Phil Harding phillipharding

View GitHub Profile
@phillipharding
phillipharding / AddSPContextToViewBag.cs
Created May 1, 2015 12:41
Add SharePoint Context to the MVC ViewBag
public static void AddAppContextToViewBag(Controller controller, HttpContextBase httpContext,
SharePointContext spContext)
{
if (httpContext == null) throw new ArgumentNullException("httpContext");
if (spContext == null) throw new ArgumentNullException("spContext");
var vb = controller.ViewBag;
vb.SPHostUrl = spContext.SPHostUrl.ToString().TrimEnd(new[] {'/'});
vb.SPAppWebUrl = spContext.SPAppWebUrl.ToString().TrimEnd(new[] {'/'});
vb.SPClientTag = spContext.SPClientTag;
@phillipharding
phillipharding / DisplaySharePointGroupMembers.js
Last active July 13, 2023 17:44
Office 365 -- Get all members of a SharePoint group and show their profile information from the site collections User Information List
(function(window, undefined) {
"use strict";
/**** The following HTML (script) template is placed on the page
<script id="po1persontemplate" type="text/x-custom-template">
<li>
<div class='people_details'>
<h3>{0}</h3>
<p class='people_job_title'>{1}</p>
<div class='people_description'>{2}</div>
function loadScript(url) {
log(">> load: url(" + url.toLowerCase() + ")");
var d = new $.Deferred();
$.getScript(url, function () {
log("<< loaded: url(" + url.toLowerCase() + ")");
d.resolve(url);
});
return d.promise();
}
cls
$programFiles = [environment]::getfolderpath("programfiles")
add-type -Path "$programFiles\SharePoint Online Management Shell\Microsoft.Online.SharePoint.PowerShell\Microsoft.SharePoint.Client.dll"
Write-Host "To disable sideLoading, enter Site Url, username and password"
$siteurl = Read-Host 'Site Url'
$username = Read-Host "User Name"
$password = Read-Host -AsSecureString 'Password'
cls
$programFiles = [environment]::getfolderpath("programfiles")
add-type -Path "$programFiles\SharePoint Online Management Shell\Microsoft.Online.SharePoint.PowerShell\Microsoft.SharePoint.Client.dll"
Write-Host "To enable sideLoading, enter Site Url, username and password"
$siteurl = Read-Host "Site Url"
$username = Read-Host "User Name"
$password = Read-Host -AsSecureString "Password"
@phillipharding
phillipharding / Restore Inherited Item Permissions.ps1
Created December 23, 2015 13:25
Restore Inherited Item Permissions
cls
$cn = SPOConnect-WithLabel -SPOUrl "" -CredentialLabel ""
$web = $cn.Web
$ctx = $cn.Context
$whatif = $false
$list = Get-List -ListName "List Name" -web $web -ClientContext $ctx
$query = [Microsoft.SharePoint.Client.CamlQuery]::CreateAllItemsQuery()
$items = $list.GetItems($query)
@phillipharding
phillipharding / SharePoint ListNavigation Breadcrumbs & Security Info.js
Last active April 16, 2016 07:44
JS and CSS for a SharePoint list/library client-side rendering template that displays folder breadcrumbs and security information
/// <reference path="../typings/jquery/jquery.d.ts"/>
/* global SP */
/* global unescapeProperly */
/* global escapeProperly */
/* global _spPageContextInfo */
/* global SPClientTemplates */
/* global pd */
(function () {
"use strict";
/*
(function (window, undefined) {
"use strict";
var $ = window.jQuery;
var document = window.document;
// SPHostUrl parameter name
var SPHostUrlKey = "SPHostUrl";
@phillipharding
phillipharding / Messing with O365 Unified Groups using Powershell.ps1
Last active January 28, 2016 13:41
List All O365 Groups and Create a New O365 Group
cls
# Connect to EXO
$creds = Get-WindowsCredentialManagerCredentials -TargetName "credential label"
Write-Host "Credentials for: $($creds.UserName)`n"
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $creds -Authentication Basic -AllowRedirection
Import-PSSession $Session | Out-Null