Skip to content

Instantly share code, notes, and snippets.

View star-crossed's full-sized avatar

Paul Choquette star-crossed

  • Everett, WA
View GitHub Profile
@star-crossed
star-crossed / O365GetTerms.ps1
Last active July 12, 2016 14:37
PowerShell: Gets terms with owner from SharePoint Online using CSOM
[CmdletBinding()]
Param(
[Parameter(Mandatory=$true, HelpMessage="This is the URL to the SharePoint Online site with your term.")]
[string]$Url,
[Parameter(Mandatory=$true, HelpMessage="This is the path to the DLLs for CSOM.")]
[string]$CSOMPath
)
Set-Strictmode -Version 1
@star-crossed
star-crossed / BulkShareWithCustomEmail.ps1
Last active May 24, 2016 13:01
Share a SharePoint Online site using a custom HTML email
[CmdletBinding(DefaultParameterSetName="UseCSV")]
Param(
[Parameter(Mandatory=$true, Position=0, ParameterSetName="UseCSV", HelpMessage="This is the path to the CSV file that has a single column, Email, which contains each email address to be invited.")]
[string]$CSVFile,
[Parameter(Mandatory=$true, Position=0, ParameterSetName="UseEmail", HelpMessage="This is the email address to be invited.")]
[string]$UserEmail,
[Parameter(Mandatory=$false, ParameterSetName="UseEmail", HelpMessage="This is the URL to the SharePoint Online site where you are inviting users.")]
[Parameter(Mandatory=$false, ParameterSetName="UseCSV", HelpMessage="This is the URL to the SharePoint Online site where you are inviting users.")]
@star-crossed
star-crossed / SetAccessRequestEmail.ps1
Last active May 11, 2016 13:46
Setting the Access Request email address for all webs in an Office 365 tenant
# replace these details (also consider using Get-Credential to enter password securely as script runs)..
$username = "REDACTED"
$password = "REDACTED"
$adminUrl = "https://REDACTED-admin.sharepoint.com"
# email address we would like all requests on all sites to go to
$email = "REDACTED"
$securePassword = ConvertTo-SecureString $Password -AsPlainText -Force
$spoCredentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($username, $securePassword)
@star-crossed
star-crossed / AddCTtoO365Group.ps1
Created April 13, 2016 21:31
Adding a custom content type to an Office 365 Group
# replace these details (also consider using Get-Credential to enter password securely as script runs)..
$username = "REDACTED"
$password = "REDACTED"
$url = "REDACTED"
$securePassword = ConvertTo-SecureString $Password -AsPlainText -Force
# the path here may need to change if you used e.g. C:\Lib..
Add-Type -Path "C:\Users\pchoquette\Source\Repos\PnP-Sites-Core\Assemblies\16.1\Microsoft.SharePoint.Client.dll"
Add-Type -Path "C:\Users\pchoquette\Source\Repos\PnP-Sites-Core\Assemblies\16.1\Microsoft.SharePoint.Client.Runtime.dll"
@star-crossed
star-crossed / HideNewItemFolder.css
Last active April 4, 2016 19:22
Some CSS to hide the Folder option in New Item menu on SharePoint document library. It also changes the text for the title of the callout menu.
.ms-newdoc-callout-main > hr,
#js-newdocWOPI-divFolder-WPQ2 {
display: none;
}
.js-callout-title {
text-indent: -9999px;
line-height: 0;
}
@star-crossed
star-crossed / sproleassignments.ps1
Last active August 29, 2015 14:27
SharePoint: Enumerate RoleAssignments on a Web (PowerShell)
Import-Module Microsoft.Online.SharePoint.Powershell
$password = Read-Host -Prompt "Enter password" -AsSecureString
[Microsoft.SharePoint.Client.ClientContext]$context = New-Object Microsoft.SharePoint.Client.ClientContext("https://jjkllc.sharepoint.com/sites/kma/extranet")
$context.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials("pchoquette@jjkllc.com", $password)
$web = $context.Web
$context.Load($web)
$context.Load($web.RoleAssignments)
$context.ExecuteQuery()
@star-crossed
star-crossed / spuniqueroles.ps1
Last active August 29, 2015 14:27
SharePoint: Test if a list has unique role assignments (PowerShell)
Import-Module Microsoft.Online.SharePoint.Powershell
Function Invoke-LoadMethod() {
param(
[Microsoft.SharePoint.Client.ClientObject]$Object = $(throw "Please provide a Client Object"),
[string]$PropertyName
)
$ctx = $Object.Context
$load = [Microsoft.SharePoint.Client.ClientContext].GetMethod("Load")
$type = $Object.GetType()
var Starcrossed = Starcrossed || {};
Starcrossed.PostRenderCallback = function(ctx) {
if (!Starcrossed.fixed) {
$("#WebPart" + ctx.wpq).find("tbody[id^='titl']").each(function(idx, elem) {
// Remove item count
$(elem).find("td").children().last().remove();
// Remove column title
@star-crossed
star-crossed / sphideinvitepeople.js
Created August 12, 2015 12:58
SharePoint: Hides the Invite People button on the New Folder form
SP.SOD.executeOrDelayUntilScriptLoaded(function() {
var oldDisplayCreateSharedFolderDialog = DisplayCreateSharedFolderDialog;
DisplayCreateSharedFolderDialog = function (rootFolder, webPartID, userSource) {
oldDisplayCreateSharedFolderDialog(rootFolder, webPartID, userSource);
$("#csfd_invitePeopleBtn").hide();
};
}, "createsharedfolderdialog.js");
@star-crossed
star-crossed / spquicklaunchmodal.js
Last active August 29, 2015 14:26
SharePoint: In Quick Launch, open navigation links under a specific header using a modal dialog
$("a[title='Actions']").next("ul").find("a").each(function (index, element) {
$(element).attr("onclick", "javascript: NewOrEditV4Core(event, '" + $(element).attr("href") + "')");
$(element).attr("href", "#");
});