Skip to content

Instantly share code, notes, and snippets.

@vaderj
vaderj / Blind-jQyery-Select.js
Last active June 12, 2018 17:06
Insert a parameter for flash "blind" (unable to use standard jQuery / DOM selectors due to encapsulation within nested <HTML><body></body></HTML>) #Javascript #SharePoint
$("<param name="wmode" value="transparent" />").insertBefore($(".ctl00_ctl50_g_d370373b_d026_4d10_95e6_b036fd690c31").contents().find('param.name:contains("allowFullScreen")'))
# Win7 Powershell script to resize Minecraft to 1280x720 (HD for fraps youtube capture)
# use by typing the following at a command prompt:
# > PowerShell -ExecutionPolicy Bypass -File minecraft-sethd.ps1
# refs:
# http://stackoverflow.com/questions/2556872/how-to-set-foreground-window-from-powershell-event-subscriber-action
# http://richardspowershellblog.wordpress.com/2011/07/23/moving-windows/
# http://www.suite101.com/content/client-area-size-with-movewindow-a17846
@vaderj
vaderj / disable_site_collection_feature.cs
Last active June 12, 2018 15:01
Enable a Site Collection feature via CSOM #C# SharePoint #SOAP #CSOM
protected void removeMasterPage(object sender, EventArgs e)
{
var url = "<URL to site>"
using (ClientContext clientContext = new ClientContext(url))
{
Site spsite = clientContext.Site;
FeatureCollection siteFeatures = spsite.Features;
clientContext.Load(siteFeatures);
Guid masterPageFeatureGuid = new Guid("efcd0dac-835c-40ca-af13-c868d6cc13db");
siteFeatures.Remove(masterPageFeatureGuid, true);
@vaderj
vaderj / enable_disable_site_collection_feature.js
Last active June 12, 2018 16:55
Enable / Disable Site Collection Feature via JavaScript / ECMAScript #Javascript #SharePoint #SOAP
function OnSuccess(sender, args) {
alert("Success!");
}
function OnFail(sender, args) {
alert("Fail: " + args.get_message() + "\n" + args.get_stackTrace());
}
function ActivateFeature(url,guid)
{
#Set up default variables
#My Site URL
$mySiteUrl = "http://mysite/"
#The part of the picture URL you are trying to find
$currentURLValue = "http://mypersonalsite"
#The value that will replace the above
$newURLValue = "http://mysite:80"
@vaderj
vaderj / Add-new-property-bag-property-JSOM.js
Last active June 12, 2018 16:54
Add a new property to the SPWeb property bag in JSOM #Javascript #SharePoint #SOAP
function AddWebSiteProperties(siteUrl) {
var clientContext = new SP.ClientContext(siteUrl);
oWebsite = clientContext.get_web();
alert(oWebsite);
clientContext.load(oWebsite);
alert("Load");
var props = oWebsite.get_allProperties();
@vaderj
vaderj / EmailUsersFile.ps1
Last active June 11, 2018 20:35
Email a file to one or more users via PowerShell #PowerShell
function emailResults()
{
$fromEmail = "[email protected]" ;
$toEmail = "[email protected]","[email protected]";
$smtp = "mail.domain.local" ;
$mailSubject = "Top search queries for the week of " + $curDate ;
$mailMsg = "<html><body><p> Please see the attached for this weeks top search queries</p>
$Assem = (
"Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" ,
"Microsoft.SharePoint.Publishing, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c"
)
$Source = @"
using Microsoft.SharePoint.Publishing.Administration;
using System;
@vaderj
vaderj / SQL-offline-online-exclusive-access.sql
Last active June 12, 2018 16:53
Set database to offline / online so SQL can gain exclusive access #SQL
alter database DEV13_Service_ManagedMetadata
set offline with rollback immediate
go
alter database DEV13_Service_ManagedMetadata
set online
go
@vaderj
vaderj / Update-SQL-FireWall.ps1
Last active June 12, 2018 16:53
Open firewall ports on a fresh SQL server #PowerShell #Windows #Firewall #SQL
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned
#Enabling SQL Server Ports
New-NetFirewallRule -DisplayName “SQL Server” -Direction Inbound –Protocol TCP –LocalPort 1433 -Action allow
New-NetFirewallRule -DisplayName “SQL Admin Connection” -Direction Inbound –Protocol TCP –LocalPort 1434 -Action allow
New-NetFirewallRule -DisplayName “SQL Database Management” -Direction Inbound –Protocol UDP –LocalPort 1434 -Action allow
New-NetFirewallRule -DisplayName “SQL Service Broker” -Direction Inbound –Protocol TCP –LocalPort 4022 -Action allow
New-NetFirewallRule -DisplayName “SQL Debugger/RPC” -Direction Inbound –Protocol TCP –LocalPort 135 -Action allow
#Enabling SQL Analysis Ports
New-NetFirewallRule -DisplayName “SQL Analysis Services” -Direction Inbound –Protocol TCP –LocalPort 2383 -Action allow
New-NetFirewallRule -DisplayName “SQL Browser” -Direction Inbound –Protocol TCP –LocalPort 2382 -Action allow