Skip to content

Instantly share code, notes, and snippets.

View ktskumar's full-sized avatar

Shantha Kumar T ktskumar

View GitHub Profile
@ktskumar
ktskumar / m365.exportallpagecontrols.ps1
Created June 7, 2021 15:54
Export all controls or webparts from all modern site pages in a site using Microsoft 365 CLI
#Export all webpart or control information from all pages in a SharePoint site to CSV format
###
$outputfilepath = "<Output fodler>\webparts.csv"
$weburl = "https://contoso.sharepoint.com"
#Validate login in
$m365Status = m365 status
if ($m365Status -eq "Logged Out") {
m365 login
}
@ktskumar
ktskumar / spPostRequest.js
Created June 6, 2021 05:39
HTTP Post request to be used with SharePoint Online REST API to do the post activities
// POST request Call
function RestRequest(url, params) {
var req = new XMLHttpRequest();
return new Promise(function(resolve, reject) {
req.onreadystatechange = function() {
if (req.readyState != 4) // Loaded
return;
if (req.status >= 200 && req.status < 300) {
resolve(req);
} else {
@ktskumar
ktskumar / SyncFlowInstances.js
Created June 6, 2021 05:29
Retrieves the Flow instances associated to the SharePoint List using REST API
/* **** RUN THIS SNIPPET in Browser Developer Console to see the output **** */
// POST request Call
function RestRequest(url, params) {
var req = new XMLHttpRequest();
return new Promise(function(resolve, reject) {
req.onreadystatechange = function() {
if (req.readyState != 4) // Loaded
return;
if (req.status >= 200 && req.status < 300) {
resolve(req);
@ktskumar
ktskumar / Syncflowtemplates.js
Created June 6, 2021 05:17
Retrieves the Flow templates associated to the SharePoint List using REST API
/* **** RUN THIS SNIPPET in Browser Developer Console to see the output **** */
// POST request Call
function RestRequest(url, params) {
var req = new XMLHttpRequest();
return new Promise(function(resolve, reject) {
req.onreadystatechange = function() {
if (req.readyState != 4) // Loaded
return;
if (req.status >= 200 && req.status < 300) {
resolve(req);
@ktskumar
ktskumar / exportflowrunhistories.ps1
Created June 5, 2021 06:10
Export all flow run histories from the Default Environment in Power Platform
Write-Host '****** Export All Flow run histories into CSV ******'
#Provide Ouput Folder Path
$outputPath = "<Output Folder Path>"
$timestamp = Get-Date -Format "yyyymmddhhmmss"
$flowhistoryValues = @()
$environmentId = $(m365 flow environment list --query "[?contains(name,'Default')]" -o json | ConvertFrom-Json).Name
$flows = m365 flow list --environment $environmentId -o json | ConvertFrom-Json
@ktskumar
ktskumar / upgradespfxtov1.12.1.json
Created June 3, 2021 06:38
Upgrade SPFX v1.10.x to V1.12.1
Execute in bash
-----------------------
npm un -S @types/webpack-env @types/es6-promise
npm un -D @types/chai @types/mocha
npm i -SE @microsoft/sp-core-library@1.12.1 @microsoft/sp-lodash-subset@1.12.1 @microsoft/sp-office-ui-fabric-core@1.12.1 @microsoft/sp-webpart-base@1.12.1 @microsoft/sp-property-pane@1.12.1
npm i -DE @microsoft/sp-build-web@1.12.1 @microsoft/sp-module-interfaces@1.12.1 @microsoft/sp-webpart-workbench@1.12.1 @microsoft/sp-tslint-rules@1.12.1 gulp@4.0.2 @microsoft/rush-stack-compiler-3.7@0.2.3 @types/webpack-env@1.13.1 @types/es6-promise@0.0.33
npm dedupe
rm ".editorconfig"
./config/copy-assets.json
@ktskumar
ktskumar / m365.exportallListData.ps1
Last active June 2, 2021 12:54
Export all list data from a SharePoint Site using Microsoft 365 CLI
#Export all lists properties (Specified in $listProperties variable) from the SharePoint in to CSV format
###
$outputfilepath = "<PUTYOURPATHHERE.csv>"
$weburl = "https://contoso.sharepoint.com/"
# Provide List Properties in below variable
$listProperties = @('Title', 'Url', 'Id')
###
Write-host 'ensure logged in'
$m365Status = m365 status
if ($m365Status -eq "Logged Out") {
@ktskumar
ktskumar / m365.getcheckedoutfiles.ps1
Created May 31, 2021 02:36
Fetch checked out files from SharePoint library using Microsoft 365 CLI
Write-host 'ensure logged in'
$m365Status = m365 status
if($m3656Status -eq "Logged Out"){
m365 login
}
#Initialize variables
$siteUrl ='https://contoso.sharepoint.com'
$library ='Documents'
@ktskumar
ktskumar / m365powerplatformenvironments.js
Last active May 29, 2021 10:49
Access Microsoft Power Platform Environments through REST API
//Try this code in Microsoft Power Automate Home page
function getRequest(url) {
var request = new XMLHttpRequest();
return new Promise(function(resolve, reject) {
request.onreadystatechange = function() {
if (request.readyState !== 4) return;
if (request.status >= 200 && request.status < 300) {
resolve(request);
} else {
@ktskumar
ktskumar / m365powerplatformconnections.js
Created May 29, 2021 06:39
Microsoft PowerPlatform Connections
function getRequest(url) {
var request = new XMLHttpRequest();
return new Promise(function(resolve, reject) {
request.onreadystatechange = function() {
if (request.readyState !== 4) return;
if (request.status >= 200 && request.status < 300) {
resolve(request);
} else {
reject({
status: request.status,