Skip to content

Instantly share code, notes, and snippets.

View cchitsiang's full-sized avatar
💭
🤖 AI & the Future of Work | 🏗️ Software Architecture & Design

Chew Chit Siang cchitsiang

💭
🤖 AI & the Future of Work | 🏗️ Software Architecture & Design
  • Kuala Lumpur, Malaysia
  • 21:09 (UTC +08:00)
View GitHub Profile
@cchitsiang
cchitsiang / RecoverSuspectMode
Created November 3, 2013 18:19
Recover SharePoint 2013 Databases from Suspect Mode
EXEC sp_resetstatus 'SharePoint_Config';
ALTER DATABASE SharePoint_Config SET EMERGENCY
DBCC checkdb('SharePoint_Config')
ALTER DATABASE SharePoint_Config SET SINGLE_USER WITH ROLLBACK IMMEDIATE
DBCC CheckDB ('SharePoint_Config', REPAIR_ALLOW_DATA_LOSS)
ALTER DATABASE SharePoint_Config SET MULTI_USER
DBCC CheckDB ('SharePoint_Config')
@cchitsiang
cchitsiang / closeConnection.aspx
Created November 6, 2013 03:00
Login as another user
http://siteurl/_layouts/closeConnection.aspx?loginasanotheruser=true
@cchitsiang
cchitsiang / print.js
Created November 7, 2013 05:01
JavaScript Print: Bypass Printer Dialog in IE and Firefox
var OLECMDID = 6;
/* OLECMDID values: * 6 - print * 7 - print preview * 1 - open window * 4 - Save As */
if (navigator.appName == "Microsoft Internet Explorer")
{
var PrintCommand = '<object ID="PrintCommandObject" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></object>';
document.body.insertAdjacentHTML('beforeEnd', PrintCommand);
if(PrintCommandObject)
{
try
{
using System;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.DirectoryServices;
using System.Collections.Generic;
[WebService(Namespace = "http://tempuri.org")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class AppServerService : System.Web.Services.WebService
Add-PsSnapin Microsoft.SharePoint.PowerShell
#Do not modify anything in the script from here onwards
function Get-ScriptDirectory
{
$Invocation = (Get-Variable MyInvocation -Scope 1).Value
Split-Path $Invocation.MyCommand.Path
}
function Deploy-Solution{
Usage
If you’re saving the script to a file, say “Remove-AllSPSolutions.ps1” then remember to load the script before invoking it with:
. .Remove-AllSPSolutions.ps1
You can uninstall all deployed solutions with the following command:
Uninstall-AllSPSolutions -Confirm
And then remove them with:
Script Usage:
1. Copy paste the below script in a text file and save the file as say “CleanupFarmSolutionStore.ps1″.
2. Run SharePoint 2010 Management Shell and change directory to where you saved above file.
3. Run command as > .\CleanupFarmSolutionStore.ps1 -Confirm $false
Note: Setting parameter -Confirm to false will not ask for confirmation before uninstalling and removing the solution from farm solution store. Set it to true for asking the confirmation.
@cchitsiang
cchitsiang / vsshortcut
Created November 17, 2013 17:09
Visual Studio Shortcut
F5 / Ctrl+F5 - Debugging
Ctrl-M + Ctrl-O - collapse all code to definitions.
Ctrl-M + Ctrl-P - used to expand all code.
Ctrl-K + Ctrl-S is used to surrounded a block of code to an specific block or control.
Ctrl-(+) + Ctrl-. - Resolve namespace
powershell -ExecutionPolicy unrestricted -command blue_green_deploy.ps1
-buildZipFile package.zip -server WEBSERVER -siteName WebSite
-blueIISPath D:\Web_Blue\ -blueNetworkPath \\WEBSERVER\Web_Blue\
-greenIISPath D:\Web_Green\ -greenNetworkPath \\WEBSERVER\Web_Green\;
@cchitsiang
cchitsiang / checkwebapppool.ps1
Created November 29, 2013 08:34
Check SharePoint Central Administration Web Application Pool Status
$apppool = [Microsoft.SharePoint.Administration.SPWebService]::AdministrationService.ApplicationPools
$appPoolStatus = Get-WebAppPoolState $apppool.name
$appPoolStatus.Value