Add SharePoint remote event receivers using PowerShell

You can use the following PowerShell script to add a remote event receiver in SharePoint 2013/2016:   Add-Type -Path “C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.dll” Add-Type -Path “C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.Runtime.dll” #Site & context $siteUrl = “https://siteurl/” $listTitle = “listTitle”   $clientContext = New-Object Microsoft.SharePoint.Client.ClientContext($siteUrl) $clientContext.Credentials = New-Object System.Net.NetworkCredential(“domain\user”, “pass”)   function addListItemRemoteEventReceiver([Microsoft.SharePoint.Client.ClientContext]$context,…


Remove Read-Only lock from SharePoint 2013/2016 site collection

Set/Remove Read-Only lock from SharePoint 2013/2016 site collection using PowerShell:   $siteUrl = “http://mysiteurl” #mark site as not locked $s = get-spsite $siteUrl $s.WriteLocked = $false set-spsite $siteUrl -LockState Unlock $s.Archived = $false   #mark site as read-only set-spsite $siteUrl -LockState ReadOnly


AccessKey too long, cannot be more than one character – SharePoint 2013 with March 2018 update

After installing March 2018 update for SharePoint 2013 you may get this error when trying to configure sync in User Profile Service Application:   Application error when access /_layouts/15/ProfileSynchronizationServiceProvisionPage.aspx, Error=AccessKey too long, cannot be more than one character. Parameter name: value at System.Web.UI.WebControls.WebControl.set_AccessKey(String value) at Microsoft.SharePoint.Portal.WebControls.InputFormButtonAtBottom.set_AccessKeyLocId(LocStringId value) at ASP._layouts_15_profilesynchronizationserviceprovisionpage_aspx.__BuildControl__control11() at ASP._layouts_15_profilesynchronizationserviceprovisionpage_aspx.__BuildControlProfileSyncProvisionSettingsForm() at ASP._layouts_15_profilesynchronizationserviceprovisionpage_aspx.__BuildControl__control4(Control __ctrl) at…


SharePoint – create MMS column from PowerShell

Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue #Variables $WebURL=”” $ListName=”DL” $FieldName=”TempMMSField” #taxonomy related variables $termStoreName = “Managed Metadata Service” $termStoreGroup = “Global Terms” $termSetName = “Topic” #Get the web and List $Web = Get-SPWeb $WebURL $List = $Web.Lists[$ListName] #Check if the column with same name exists in the list if(!($List.Fields.ContainsField($FieldName))) { #Get the Termset from Term store $TaxonomySession…


SharePoint – add all wsps from a folder

foreach ($item in (Get-Childitem -path c:\temp\wsp)) { $location = “c:\temp\wsp\” + $item.Name add-spsolution -literalpath $location }