Skip to content

Instantly share code, notes, and snippets.

View kendomen's full-sized avatar

Ken Domen kendomen

View GitHub Profile
@glapointe
glapointe / Custom Windows PowerShell Function to Make SharePoint REST Service Calls
Last active May 1, 2020 18:00
Sends an HTTP or HTTPS request to a SharePoint Online REST-compliant web service using Windows PowerShell.
The functions in this Gist are part of an article series on ITUnity.com.
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"
$AdminUrl = "https://tenant-admin.sharepoint.com/"
$UserName = "username@tenant.onmicrosoft.com"
$Password = "password"
$SecurePassword = $Password | ConvertTo-SecureString -AsPlainText -Force
$Credentials = New-Object -TypeName System.Management.Automation.PSCredential -argumentlist $userName, $SecurePassword
$SPOCredentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($UserName, $SecurePassword)
@chrisobriensp
chrisobriensp / AddRemoteEventReceiver.ps1
Last active June 13, 2023 15:17
PowerShell/CSOM to add a Remote Event Receiver to a SharePoint list
. .\TopOfScript_PSCSOM.ps1
function addListItemRemoteEventReceiver([Microsoft.SharePoint.Client.ClientContext]$context, [string]$listName,
[Microsoft.SharePoint.Client.EventReceiverType]$eventType, [Microsoft.SharePoint.Client.EventReceiverSynchronization]$synchronization,
[string]$receiverName, [string]$receiverUrl, [string]$receiverAssemblyName, [string]$receiverClassName)
{
$list = $context.Web.Lists.GetByTitle($listName);
$context.Load($list)
$eventReceivers = $list.EventReceivers
$context.Load($eventReceivers)