Skip to content

Instantly share code, notes, and snippets.

View dev-kperera's full-sized avatar
🤵‍♂️
On Code

Kushan Perera dev-kperera

🤵‍♂️
On Code
View GitHub Profile
@dev-kperera
dev-kperera / GetSharePointFormDigestSvc.js
Created May 16, 2016 16:52
Angular Js service to get SharePoint Form Digest value (X-RequestDigest) value
(function(){
'use strict'
// Service that returns form digest value
angular
.module('app')
.service('getFormDigestService', function($http, $q){
//Define the service call
this.getFormDigest = function(){
//Fetch the Url
@dev-kperera
dev-kperera / UpdateSharePointFieldWithMMSColumn.js
Created September 4, 2016 09:39
Updating SharePoint list or library field which consist of MMS (Managed Metadata or Taxonomy) column with Angular JS and JSOM
(function () {
'use strict';
// define controller
var controllerId = "MMSDevCtrl";
angular
.module('app')
.controller(controllerId, ['$q', mmsDevController]);
@dev-kperera
dev-kperera / getTermIdForTermValue.js
Created September 11, 2016 10:25
Get/ Resolve Term ID for Term Value in SharePoint.
// Resolve Term ID for the Term Value
function getTermIdForTermValue(siteUri, listName, fieldName, termValue) {
//Define
var deferred = $q.defer()
, termId;
var clientContext = new SP.ClientContext(siteUrl);
var list = clientContext.get_web().get_lists().getByTitle(listName);
//Tx field
var field = list.get_fields().getByInternalNameOrTitle(fieldName);
var txField = clientContext.castTo(field, SP.Taxonomy.TaxonomyField);
@dev-kperera
dev-kperera / run.csx
Last active January 30, 2018 21:51
Azure Functions with SharePoint Online CSOM C#
#r "Microsoft.SharePoint.Client.Runtime.dll"
#r "Microsoft.SharePoint.Client.dll"
using System;
using System.Security;
using System.Configuration;
using Microsoft.SharePoint.Client;
public static void Run(TimerInfo myTimer, TraceWriter log)
{
@dev-kperera
dev-kperera / Outlook - Remove Custom Signature.ps1
Last active December 19, 2019 19:59
While in the progress of deploying signatures with centralized location in Office 365, I found this piece of code to be used.
# Remove signures from users when you dont have centralized server
$MSLocation = $env:USERPROFILE.ToString() + "\AppData\Roaming\Microsoft\"
$SignaturesLocation = $MSLocation + "Signatures"
$BackupFolder = $MSLocation + "Signatures Backup"
Try {
"User profile location" + $SignaturesLocation
@dev-kperera
dev-kperera / RemoveOutlookCustomSignatures.ps1
Last active May 22, 2018 15:54
While in the progress of deploying signatures with centralized location in Office 365, I found this piece of code to be used to remove user custom signatures. It will automate removal of signatures in Windows machines. Tested in Windows 2012, 2016, 7, 8, and 10.
# Remove signures from users when you dont have centralized server
$MSLocation = $env:USERPROFILE.ToString() + "\AppData\Roaming\Microsoft\"
$SignaturesLocation = $MSLocation + "Signatures"
Try {
"User profile location - " + $SignaturesLocation
cd $SignaturesLocation
Get-ChildItem *.txt | Rename-Item -NewName { $_.name -Replace '\.txt$','.txt.bkp' }
@dev-kperera
dev-kperera / Configuration.xml
Created May 25, 2018 18:40
If you not deployed Office 365 properly on a Windows server which promoted as Terminal Server (RDS) it will throw error when openning Office applications. By using this configuration XML it will force you to pull licenses from Office 365 but not from licensing server.
<Configuration>
<Add OfficeClientEdition="64" Channel="Monthly">
<Product ID="O365ProPlusRetail">
<Language ID="en-us" />
</Product>
<Product ID="VisioProRetail">
<Language ID="en-us" />
</Product>
</Add>
@dev-kperera
dev-kperera / header.ps1
Created June 26, 2018 13:09
Source Code Header Templates - PowerShell
<#
.DESCRIPTION
.DEPENDENCIES
.INPUTS
.OUTPUTS
@dev-kperera
dev-kperera / settings.json
Created September 30, 2018 12:25
Visual Studio (VS) Code My Favorite Settings
{
"git.ignoreMissingGitWarning": true,
"window.zoomLevel": 0.5,
"breadcrumbs.enabled": true,
"editor.wordWrap": "on",
"editor.formatOnPaste": true,
"editor.formatOnSave": true,
"editor.formatOnType": true,
"editor.quickSuggestions": {
"other": true,
@dev-kperera
dev-kperera / ConnectSharePointOnline.ps1
Created April 2, 2019 18:13
SharePoint site owners have new options for applying custom styles and colors to sites that make it easier to define and manage themes across site collections
# Commands to connect SharePoint Online
$adminUPN="kushan@contoso.onmicrosoft.com"
$orgName= Read-Host -Prompt 'Name of your Office 365 organization, example: contoso'
$userCredential = Get-Credential -UserName $adminUPN -Message "Type the password."
Connect-SPOService -Url https://$orgName-admin.sharepoint.com -Credential $userCredential
# Verify SharePont Online Management Shell
Get-Module -Name Microsoft.Online.SharePoint.PowerShell -ListAvailable | Select Name,Version