Skip to content

Instantly share code, notes, and snippets.

DavidWise / Upload-FileToSharePoint.ps1
Last active December 16, 2015 20:49
Powershell script to upload a file to a SharePoint document Library. This is meant to be called from other scripts like a cmdlet. This also handles document libraries that require check-in/out and document approval
[string] $listUrl = $null, # = "",
[string] $file = $null, # = "C:\SomeFolder\SomeFile.txt",
[string] $checkInComment = "Background Process Upload",
[bool] $publishMajorVersion = $true,
[bool] $approve = $true, # approve it if if approval is required
[string] $approvalComment = "Approved by background process",
[bool] $useFileTimes = $false # use the original file times for SharePoint created/modified
# Original Author: Lee Holmes,
# Modified by: Helge Klein,
# (
# Modified again by: David Wise,
# Syntax highlights a PowerShell script.
# Usage: Supply the script to syntax hightligh as first and only parameter
# Output: Copy of original script with extension ".html"
DavidWise / SPCmdAsUser.cmd
Created December 4, 2012 17:10
Easily run the SharePoint Command Shell as a different user ID
@echo off
set PSshell="C:\Windows\System32\WindowsPowerShell\v1.0\PowerShell.exe -NoExit & 'C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\CONFIG\POWERSHELL\Registration\\sharepoint.ps1'\""
runas /user:myDomain\ServiceAccountName /savecred %PSshell%
if errorlevel 1 pause
DavidWise / MultiMasterHttpModule.cs
Created July 23, 2012 22:14
An httpModule that allows the master pages in SharePoint to be overridden
using System;
using System.Web;
using System.Web.UI;
using System.IO;
public class MasterPageModule : IHttpModule
public void Init(HttpApplication context)
context.PreRequestHandlerExecute += new EventHandler(context_PreRequestHandlerExecute);
DavidWise / IncrementAssemblyFileVersion.ps1
Created July 12, 2012 18:23
Automatically set the AssemblyFileVersion for a project with each build in Visual Studio
#used to make it easier to spot the comments from the script in the Build Output window
$msgPrefix=" | "
#useful when testing the script - simply point this to the root of a folder that contains a project
#and the script can be run via PowerShell or ISE without having to constantly build via VS
#the default location for the TFS files. You may need to update this for your specific installation