Skip to content

Instantly share code, notes, and snippets.

View rheid's full-sized avatar

Ralf Heid rheid

View GitHub Profile
@rheid
rheid / function CreateTeamsite()
Last active December 22, 2015 09:49
SharePoint 2013 REST Call to a List Item
function CreateTeamsite() {
var url = _spPageContextInfo.siteAbsoluteUrl;
teamsiteValues = {
"Title": $('input[id=ctl00_PlaceHolderMain_txt_name]').val(),
"BusinessUnit": $("#sel_bu option:selected").text(),
"Description_x002f_Purpose":"test", // $('input[id=ctl00_PlaceHolderMain_txt_purpose]').val(),
"Members": peoplePicker_Members.GetAllUserKeys(),
"SecondaryOwner": peoplePicker_secondaryOwner.GetAllUserKeys(),
$ver = $host | select version
if ($ver.Version.Major -gt 1) {$Host.Runspace.ThreadOptions = "ReuseThread"}
Add-PsSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
Import-Module WebAdministration -ErrorAction SilentlyContinue
##
#This Script Creates SharePoint Web Applications
##
##
@rheid
rheid / spsp.cs
Created February 20, 2014 20:33
How to copy list items with people and group columns between site collections using CSOM
using System;
using System.Collections.Generic;
using System.Net;
using System.Security.Principal;
using System.Security;
using Microsoft.SharePoint.Client;
namespace StefanG.Tools
{
class CopyPeopleColumn
@rheid
rheid / workflow.cs
Created March 11, 2014 20:46
Start a SharePoint 2013 Workflow with CSOM
The way workflow get triggered from code behind is different in SharePoint 2013
//Instantiate Workflow Manager
var wsm = new Microsoft.SharePoint.WorkflowServices.WorkflowServicesManager(web);
//Get Workflow Instane ID
var subscription = wsm.GetWorkflowSubscriptionService().GetSubscription(new Guid("{2DC2893B-DEC0-433A-BB34-8DC0CD9CC8FC}"));
Function ChangeSiteCollectionAdministrators
{
Write-Host -Foregroundcolor green "- Changing the site collection administrators"
$site = Get-SPSite | ?{$_.Url -like "*sites/tempSite*"}
If ($site -ne $null)
{
Set-SPSite -Identity $site.Url -OwnerAlias "DOMAIN\farmacc" -SecondaryOwnerAlias "DOMAIN\svcacc"
Write-Host -Foregroundcolor white "- Site Collection Administrators for '$site' is changed."
}
}
@rheid
rheid / Get-CrawledProperties.ps1
Created March 16, 2014 17:08
This script will allow show you the Crawled Property names and values for a Document. Using this information you can create Search Managed
#------------------------------------------------------------------------------------------------------
# Name: Get-CrawledProperties.ps1
# Description: This script will show you the crawled property names for a document library
# Usage: Run the function with a Document URL as the parameter.
# By: Ivan Josipovic, Softlanding.ca
#------------------------------------------------------------------------------------------------------
Function Get-CrawledPropertyNames([string]$DocURL){
$DocURL = $DocURL.Replace("%20"," ")
$webfound = $false
$weburl = $DocURL
Param(
[string] $url = $(Read-Host -prompt "Enter Site Collection URL: ")
)
if ( (Get-PSSnapin -Name Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue) -eq $null )
{
Add-PsSnapin Microsoft.SharePoint.PowerShell
}
Write-Host " "
@rheid
rheid / InsertSharepointIteam.cs
Created August 7, 2014 17:05
Insert a SharePoint Iteam
using System;
using Microsoft.SharePoint.Client;
using SP = Microsoft.SharePoint.Client;
namespace Microsoft.SDK.SharePointServices.Samples
{
class CreateListItem
{
static void Main()
{
@rheid
rheid / MissingSetupFileDetails.ps1
Created August 8, 2014 14:44
Missing Setup Files in SharePoint 2013
param (
[string]$DBserver = $(throw "Missing server name (please use -dbserver [dbserver])"),
[string]$path = $(throw "Missing input file (please use -path [path\file.txt])")
)
#Set Variables
$input = @(Get-Content $path)
#Addin SharePoint2010 PowerShell Snapin
Add-PSSnapin -Name Microsoft.SharePoint.PowerShell
#Declare Log File
Function StartTracing
@rheid
rheid / getFields.ps1
Created August 8, 2014 15:17
Read SharePoint Fields with PowerShell
$web = Get-SPWeb http://sharepoint/sites/training/salestraining
$list = $web.Lists["Announcements"]
$list.fields | select Title, InternalName, StaticName | sort title | ft -AutoSize