Skip to content

Instantly share code, notes, and snippets.

View rheid's full-sized avatar

Ralf Heid rheid

View GitHub Profile
@rheid
rheid / createSPWebFromTemplate.js
Created February 12, 2017 19:52
SharePoint JS CSOM code to create a subsite using a custom Site Template
var webUrl = "newSubSite",
webTitle = "New Sub Site",
webDesc = "Description about the new web/site";
var siteTemplate;
var CONST_PROJECT_TEMPLATE = "Custom Project Template";
var ctx = SP.ClientContext.get_current();
var webTemplates = ctx.get_web().getAvailableWebTemplates(1033, false);
ctx.load(webTemplates);
@rheid
rheid / changeSPWelcomePage.js
Created February 12, 2017 19:51
Change SharePoint Welcome Page with CSCOM
SP.SOD.executeFunc('SP.js', 'SP.ClientContext', function() {
var clientContext = new SP.ClientContext.get_current();
var web = clientContext.get_web();
var rootFolder = web.get_rootFolder();
clientContext.load(rootFolder);
clientContext.executeQueryAsync(function() {
console.log("WebWelcome Page is: " + rootFolder.get_welcomePage());
@rheid
rheid / disableService.ps1
Created January 31, 2017 15:14
Disable Office 365 Service
#MAKE SURE YOU ARE CONNECTED TO OFFICE 365 BEFORE RUNNING THIS SCRIPT
#If you don't know how check out: http://powershell.office.com/script-samples/connect-to-Azure-AD
#The initial script was built for Yammer removal by Vlad Catrinescu and can be found here: http://spvlad.com/1VXll7f
#Updated by Drew Madelung to support O365 Planner GA
#This script will go through all licensed users and first check if they have the planner preview license and remove it and then check for the GA O365 planner license and disable it
#This script will re-enable all other services EXCEPT planner, If you want to disable more add them comma seaparated to the $disabledplans variable.
#For example to disable Yammer and Planner use this: $disableplans = "PROJECTWORKMANAGEMENT", "YAMMER_ENTERPRISE"
#Set disabled plans (only Planner to start)
$disableplans = "PROJECTWORKMANAGEMENT"
@rheid
rheid / RemoveAzureVMFull.ps1
Created December 7, 2016 13:16
Remove Azure VM Full
# Login and select Azure Subscription.
Login-AzureRmAccount -TenantId db87e8a4-ab1f-4a72-844d-f9ad89ad4258
Select-AzureRmSubscription -SubscriptionId 72e4639f-8f07-45c5-9347-9e3dd84691db
# Get all Azure VM's in subscription so they can be added to drop down list.
$listvms = Get-AzureRmVM
$extractvmname = $listvms.Name
@rheid
rheid / sqldropdb.sql
Created November 19, 2016 09:45
Drop multiple databases in SQL Server
USE master;
Go
SELECT 'DROP DATABASE '+ name
FROM sys.databases WHERE name like 'sp16%';
GO
@rheid
rheid / setSPLookup.js
Created November 8, 2016 15:56
SharePoint Lookup in other List (jQuery)
// A $( document ).ready() block.
$( document ).ready(function() {
console.log( "ready!" );
var itemId = getUrlParameter("EventId");
setLookupValue("Schulung_x002f_Unterweisung_6a5704d6-f2e4-46f4-9cf6-834e47e66d77_\\$LookupField", itemId);
$("select[id=Schulung_x002f_Unterweisung_6a5704d6-f2e4-46f4-9cf6-834e47e66d77_\\$LookupField]").change(checkBooking);
$("select[id=Schulung_x002f_Unterweisung_6a5704d6-f2e4-46f4-9cf6-834e47e66d77_\\$LookupField]").trigger( "change" );
})
@rheid
rheid / createSPUserProfile.ps1
Last active September 30, 2016 15:42
SharePoint: Provisioning user profile service using PowerShell
Add-PsSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
# assume your farm account is managed account
$FarmSvcAccountName = "AD\YourFarmServiceAccount"
$FarmSvcAccount= (Get-SPManagedAccount $FarmSvcAccountName)
$DatabaseServer = "YourDBServer"
$AppServer = "YourAppServer"
$MySitePort = 85
$MySiteUrl="http://{0}:{1}" -f $AppServer, $MySitePort
@rheid
rheid / EnableSideLoading.ps1
Created August 30, 2016 08:53
Enable Sideloading of apps for Office 365 Site Collections
$programFiles = [environment]::getfolderpath("programfiles")
add-type -Path $programFiles'\SharePoint Online Management Shell\' + `
'Microsoft.Online.SharePoint.PowerShell\Microsoft.SharePoint.Client.dll'
Write-Host `
'To enable SharePoint app sideLoading, ' + `
'enter Site Url, username and password'
$siteurl = Read-Host 'Site Url'
@rheid
rheid / Enumerate-LargeListsInSite.ps1
Created August 29, 2016 15:19
Enumerate-LargeListsInSite in SharePoint Farms
[reflection.assembly]::loadwithpartialname("Microsoft.SharePoint")
$cs = [microsoft.sharepoint.administration.spwebservice]::ContentService
$global:largeListThreshhold = 2000
function Is-Admin([Microsoft.SharePoint.SPRoleAssignment]$roleAssignment)
{
return (($roleAssignment.roledefinitionbindings | where { ($_.BasePermissions.ToString() -match "ManageLists|ManageWeb|FullMask") }) -ne $null)
}
function Write-ListDetails($list,$web,$site)
@rheid
rheid / changeListURL.ps1
Created July 10, 2016 17:26
SharePoint Change ListItem URL
if((Get-PSSnapin | Where {$_.Name -eq "Microsoft.SharePoint.PowerShell"}) -eq $null)
{
Add-PSSnapin Microsoft.SharePoint.PowerShell;
}
$web = Get-SPWeb "http://YourWeb/sites/"
$list = $web.Lists["OLD Name"]
# Display the fields, so to make sure you are grabbing the correct list in the correct site collection