Skip to content

Instantly share code, notes, and snippets.

View rheid's full-sized avatar

Ralf Heid rheid

View GitHub Profile
@rheid
rheid / sqlrole.sql
Created September 2, 2014 18:04
Read all SQL ServerRolls
Declare @Prefix varchar(255)
Declare @tmpstr varchar(MAX)
Set @Prefix = '
exec master.dbo.sp_addsrvrolemember @loginame='''
Set @tmpstr=''
Select @tmpstr = @tmpstr
+ Case When sysadmin = 1 Then @Prefix + [LoginName] + ''', @rolename=''sysadmin''' Else '' End
@rheid
rheid / addFileToTempDB.sql
Created September 4, 2014 08:00
SQL Server TempDB with multiple Files
ALTER DATABASE [tempdb]
MODIFY FILE ( NAME = N'tempdev' , SIZE = 3480000KB )
ALTER DATABASE [tempdb]
ADD File ( NAME = N'tempdev_2', FILENAME = N'G:\database\tempdev_2.ndf' , SIZE = 3480000KB , MAXSIZE = UNLIMITED, FILEGROWTH = 1024KB)
ALTER DATABASE [tempdb]
ADD File ( NAME = N'tempdev_3', FILENAME = N'G:\database\tempdev_3.ndf' , SIZE = 3480000KB , MAXSIZE = UNLIMITED, FILEGROWTH = 1024KB)
ALTER DATABASE [tempdb]
@rheid
rheid / StateService.ps1
Created September 4, 2014 10:54
Setup new The State Service
# The State Service is required in order to use the out-of-the-box workflows in
# SharePoint Server 2010 (e.g. Approval - SharePoint 2010) or any other features
# that leverage InfoPath Forms Services.
#
# When using the Farm Configuration Wizard to configure the State Service, the
# resulting database is named StateService_{GUID}. In order to avoid lengthy
# database names containing GUIDs, the State Service is configured using PowerShell.
function ConfigureStateService(
[string] $stateServiceName = $(Throw "Value cannot be null: stateServiceName"),
@rheid
rheid / AddFarmAdmin.ps1
Last active June 12, 2017 14:56
Add a new Farm Administrator in SharePoint 2013
#################################################
# Add a new Farm Administrator
#################################################
# Creates a new Farm Administrator
$newFarmAdministrator = “MC\Sp.AdminMC"
$caWebApp = Get-SPWebApplication -IncludeCentralAdministration | where-object {$_.DisplayName -eq "SharePoint Central Administration v4"}
$caSite = $caWebApp.Sites[0]
$caWeb = $caSite.RootWeb
@rheid
rheid / postandgetspfeed.js
Created December 7, 2014 16:40
Post a SharePoint Newsfeed
var feedManagerEndpoint;
// Get the SPAppWebUrl parameter from the query string and build
// the feed manager endpoint.
$(document).ready(function () {
var appweburl;
var params = document.URL.split("?")[1].split("&");
for (var i = 0; i < params.length; i = i + 1) {
var param = params[i].split("=");
if (param[0] === "SPAppWebUrl") appweburl = param[1];
@rheid
rheid / PublishContentTypes.ps1
Created December 12, 2014 11:11
Publish Content Types Using Powershell - SharePoint 2013
#Check to ensure Microsoft.SharePoint.Powershell is loaded
$snapin = Get-PSSnapin | Where-Object{$_.Name -eq ‘Microsoft.SharePoint.Powershell’}
if ($snapin -eq $null) {
Write-Output “Loading SharePoint Powershell Snapin”
Add-PSSnapin “Microsoft.SharePoint.Powershell”
}
$webAppURL = “http://intranet.mycompany.com&#8221;
#Get the site collection of your content type hub
$site = Get-SPSite “$webAppUrl/metadata/contenttypehub”
#Get the root web of the about site collection
@rheid
rheid / sptimeout.ps1
Created December 20, 2014 14:22
Setup IIS Timeout and Workflow Timeout für SharePoint 2013
Write-Host "===============================================" -ForegroundColor Yellow
Write-Host "Adding Timout Value to SharePoint Web.Config" -ForegroundColor Yellow
Write-Host "===============================================" -ForegroundColor Yellow
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
function RemoveMyEntries($webapp, $Owner)
{
$oldMods = @();
$webapp.WebConfigModifications | where-object { $_.Owner -eq $Owner } | foreach-object { $oldMods = $oldMods + $_}
@rheid
rheid / setCurrentUser.html
Created December 22, 2014 07:00
Set people column default value to current user in SharePoint 2013 using REST
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
var userid = _spPageContextInfo.userId;
function GetCurrentUser() {
var requestUri = _spPageContextInfo.webAbsoluteUrl + "/_api/web/getuserbyid(" + userid + ")";
var requestHeaders = { "accept" : "application/json;odata=verbose" };
$.ajax({
url : requestUri,
contentType : "application/json;odata=verbose",
@rheid
rheid / createspcontentdatabase.ps1
Created December 23, 2014 08:08
Create SharePoint Content Database
Write-Host "===============================================" -ForegroundColor Yellow
Write-Host " Create SharePoint Content-Databases " -ForegroundColor Yellow
Write-Host "===============================================" -ForegroundColor Yellow
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
#Site to Create
$Site = 100
#Site per SPContentDatabase
@rheid
rheid / callrestservice.js
Created February 7, 2015 16:09
NodeJS Call a Rest Service
var https = require('https');
/**
* HOW TO Make an HTTP Call - GET
*/
// options for GET
var optionsget = {
host : 'graph.facebook.com', // here only the domain name
// (no http/https !)
port : 443,