Skip to content

Instantly share code, notes, and snippets.

View ktskumar's full-sized avatar

Shantha Kumar T ktskumar

View GitHub Profile
@ktskumar
ktskumar / copy-webpart.ts
Created March 8, 2022 00:20
Copy web-part from one page to another modern page in SharePoint
/*
Below code uses the PnP JS and helps to copy the webpart from one page to another page in modern SharePoint page
*/
import { sp } from "@pnp/sp/presets/all";
(async () => {
const page = await sp.web.loadClientsidePage("/sites/portal/SitePages/page2.aspx");
const control = page.sections[1].columns[0].getControl(0);
@ktskumar
ktskumar / voice_validation.html
Last active June 13, 2022 23:40
Voice recognition and validation by comparing two speecs and determine if they are from the same speaker. Try it with your own voice!
<!DOCTYPE html>
<html>
<head>
<title>Speaker Authenticator</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/recorderjs/0.1.0/recorder.js"></script>
</head>
<body>
<div class="container">
<h1>Validate Speaker</h1>
@ktskumar
ktskumar / mgt-showgroups.html
Created December 17, 2021 10:52
HTML snippet for render groups in a responsive table
<mgt-get resource="/groups" version="v1.0" scopes="group.read" max-pages="2">
<template>
<div class="get-wrapper">
<div class="table">
<div class="row header">
<div class="cell">
Name
</div>
<div class="cell">
Email
@ktskumar
ktskumar / mgt-explorejson.html
Created December 16, 2021 14:28
Explore JSON response from mgt-get
<mgt-get resource="/me/drive" version="v1.0" scopes="file.read" max-pages="2">
<template>
<div class="objcontainer" data-for="{{a in Object.keys(this)}}">
<div class="key">{{a}}</div>
<div data-if="{{typeof(this[a]) != 'object'}}" class="value">{{this[a]}} </div>
<div data-else class="value">
<div data-for="{{b in Object.keys(this[a])}}">
<div class="key">{{b}}</div>
<div class="value">{{this[a][b]}}</div>
</div>
@ktskumar
ktskumar / mgt-profileanimation.html
Created December 7, 2021 01:41
Animate Profile using Microsoft Graph Toolkit
<mgt-person person-query="me">
<template>
<div id="outerContainer" data-if="person.personImage">
<div id="container">
<div class="item">
<img src="{{ person.personImage }}" />
</div>
<div class="circle" style="animation-delay: -3s">
</div>
<div class="circle" style="animation-delay: -2s">
@ktskumar
ktskumar / updateWriteSecurity.js
Created November 30, 2021 07:19
Change Item Level permission for SitePages Library
//Update the WriteSecurity to change the item level permissions
//Set the Edit property to Create items and edit items that were created by the user
// 1 - Create and edit all items
// 2 - Create items and edit items that were created by the user
// 3 - None
import { sp, Web } from "@pnp/sp/presets/all";
(async () => {
@ktskumar
ktskumar / spfx-mgt-showemails.htm
Created November 30, 2021 00:46
Display Recent Mails using Microsoft Graph Toolkit
<mgt-get resource="/me/messages" version="beta" scopes="mail.read" max-pages="2">
<template>
<div style="background-color:#eee;padding:8px 30px;">
<div class="email" data-for="email in value" style="padding:20px; background-color:#fff">
<h3>{{ email.subject }}</h3>
<h4>
<mgt-person person-query="{{email.sender.emailAddress.address}}" view="oneline" person-card="hover">
</mgt-person>
</h4>
<div data-if="email.bodyPreview" class="preview" innerHtml>{{email.bodyPreview}}</div>
@ktskumar
ktskumar / spHideSearchBoxinNavBar.js
Created June 17, 2021 18:02
Code helps to hide the searchbox in navbar in SharePoint Site
// 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 / exportnobirthdayusers.ps1
Created June 12, 2021 16:57
Export all the users with no birthday value set in the Profile using Microsoft 365 CLI
$outputfilepath = "< OUTPUT PATH WITH FILENAME.csv >"
Write-host 'ensure logged in'
$m365Status = m365 status
if ($m365Status -eq "Logged Out") {
m365 login
}
# Fetch all AAD users from Microsoft 365
$allusers = m365 aad user list --properties 'displayName,userPrincipalName,accountEnabled' -o json | ConvertFrom-Json
@ktskumar
ktskumar / spfxmgt-showallapplications.html
Created June 9, 2021 11:32
Show all Application Registrations using Microsoft Graph Toolkit in a SharePoint Framework webpart
<!-- THIS CODE USES THE MICROSOFT GRAPH TOOLKIT -->
<!-- USE THE MICROSOFT GRAPH TOOLKIT EDITOR WEBPART FOR BETTER RESULT -->
<!-- REFERENCE LINK: http://www.ktskumar.com/2021/06/spfx-microsoft-graph-toolkit-show-all-application-registrations-in-sharepoint/ -->
<style type="text/css">
table {
border-collapse: collapse;
margin: 0;
padding: 0;
width: 100%;
table-layout: fixed;