Skip to content

Instantly share code, notes, and snippets.

@vaderj
vaderj / sp-column-shrinker.css
Last active June 12, 2018 17:05
SharePoint - Make a rediculously huge column shrink to a normal size until hover occurs #css #SharePoint
/* http://sharepoint.stackexchange.com/questions/151473/how-to-truncate-a-multiline-column-in-a-sharepoint-list-2013 */
<style>
.ms-vb2 .ms-rtestate-field{
max-width:250px;
max-height:38px;
overflow:hidden;
}
.ms-vb2 .ms-rtestate-field:hover{
max-height:none;
@vaderj
vaderj / check-spuser-permission.js
Last active June 12, 2018 16:56
check if the current SP user has a specific permission #Javascript #REST #SharePoint
//Permission enumeration : https://msdn.microsoft.com/en-us/library/office/ee556747(v=office.14).aspx
function checkPermissions() {
var call = jQuery.ajax({
url: _spPageContextInfo.webAbsoluteUrl + "/_api/Web/effectiveBasePermissions",
type: "GET",
dataType: "json",
headers: {
Accept: "application/json;odata=verbose"
}
@vaderj
vaderj / Add-SPUser-to-site.ps1
Last active June 12, 2018 16:55
Add a user to a SharePoint site #PowerShell #SharePoint
$web = Get-SPWeb "http://portal"
function AddGroupToSite ($web, $groupName, $permLevel)
{
$account = $web.SiteGroups[$groupName]
$assignment = New-Object Microsoft.SharePoint.SPRoleAssignment($account)
$role = $web.RoleDefinitions[$permLevel]
$assignment.RoleDefinitionBindings.Add($role);
$web.RoleAssignments.Add($assignment)
}
@vaderj
vaderj / set_Site_Collection_Admin.ps1
Last active June 11, 2018 20:39
PowerShell - Open prompt as Admin user who has access, set URL var, run command #PowerShell #SharePoint
$url = "."
new-spuser -UserAlias 'domain\userName' -web $url -SiteCollectionAdmin
@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
@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
$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 / 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>
@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();
#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"