Skip to content

Instantly share code, notes, and snippets.

View svarukala's full-sized avatar
🎯
Focusing

Srinivas Varukala svarukala

🎯
Focusing
View GitHub Profile
@svarukala
svarukala / Get-AzureADAppsInfo.ps1
Last active May 10, 2023 19:38
Outputs list of all Azure AD Apps along with their expiration date, display name, owner email, credentials (passwordcredentials or keycredentials), start date, key id and usage. Useful to know the apps that are expiring and take action (renew). Since Azure AD PowerShell is being deprecated in favor of Microsoft Graph PowerShell SDK, I created a …
# Requires Azure AD PowerShell Module
#Prompts user to login using Azure Credentials
Connect-AzureAD
$results = @()
Get-AzureADApplication -All $true | %{
$app = $_
$owner = Get-AzureADApplicationOwner -ObjectId $_.ObjectID -Top 1
@svarukala
svarukala / Get-AzADAppsInfo.ps1
Created November 18, 2019 21:51
This PS script uses Azure AZ module that outputs list of all Azure AD Apps along with their expiration date, display name, credentials (passwordcredentials or keycredentials), start date, key id. Useful to know the apps that are expiring and take action (renew).
# Requires Azure AD PowerShell Module
#Prompts user to login using Azure Credentials
Connect-AzAccount
#Set the page size to your need.
$pgsize = 100;
$pg = 0;
$cnt = $null
$results = @()
@svarukala
svarukala / Upload-FileToSPOUsingACSAppOnly.ps1
Last active July 13, 2020 20:22
Sample PowerShell script to upload small and large files to SPO that uses the ACS (AppRegNew.aspx) based registered app
<#
DISCLAIMER
----------
The scripts is provided is not to be treated as an official recommendations from Microsoft. The information provided is as-is with no warranty and use at your personal risk.
PURPOSE
-------
Sample script to upload small to large files to SPO that uses the ACS (AppRegNew.aspx) based registered app.
Example SPO ACS APP REGISTRATION (Using AppRegNew.aspx page)
@svarukala
svarukala / Connect-MSGraphAuthCode.ps1
Created July 16, 2020 22:48
Sample script that connects to Microsoft Graph using Authorization Code (implies user must sign in). This script does 4 actions:
clear
# The resource URI
$resource = "https://graph.microsoft.com"
# Your Client ID and Client Secret obainted when registering your WebApp
$clientid = "GUID FOR APPID";
$clientSecret = "CLIENT SECRET FOR APP";
$redirectUri = "https://localhost"
# UrlEncode the ClientID and ClientSecret and URL's for special characters
Add-Type -AssemblyName System.Web
@svarukala
svarukala / Connect-MSGraphAuthCodeODBvsSPOPerms.ps1
Last active July 17, 2020 14:02
Sample script that connects to Microsoft Graph using Authorization Code (implies user must sign in). This script does 4 actions: 1) Read files from OneDrive for Business (ODB), 2) Read files from SPO site library 3) Create a demo file in ODB and 4) Create a demo file in SPO site
clear
# The resource URI
$resource = "https://graph.microsoft.com"
# Your Client ID and Client Secret obainted when registering your Azure AD (AAD) APP
$clientid = "AAD APP ID";
$clientSecret = "AAD APP CLIENT SECRET";
$redirectUri = "https://localhost"
# UrlEncode the ClientID and ClientSecret and URL's for special characters
Add-Type -AssemblyName System.Web
clear
# Azure AD(AAD) Application (client) ID, tenant Name and secret
$tenantName = "YOURTENANT.onmicrosoft.com"
$clientId = "AAD APP ID";
$clientSecret = "AAD APP CLIENT SECRET";
$resource = "https://graph.microsoft.com/"
$ReqTokenBody = @{
Grant_Type = "client_credentials"
Scope = "https://graph.microsoft.com/.default"
@svarukala
svarukala / Version-DocumentSetsInSPO.ps1
Last active March 22, 2021 10:38
PowerShell script to capture version of Document Sets using CSOM in SharePoint Online. This script also lists out all the Document Set content type items along with the version information from a document library using the latest CSOM library released recently (version: 16.1.20317.12000 or above). Before this release, the only way to version a D…
cls
#Import-Module Microsoft.Online.SharePoint.PowerShell
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll"
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"
Add-Type -Path "C:\Program Files\Common Files\microsoft shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.DocumentManagement.dll"
#Setting this to True will create new version for any DocSet it identifies that has zero versions existing
$CreateNewVersion = $true
$AdminPass = "password"
$AdminPassword = ConvertTo-SecureString -string $AdminPass -AsPlainText -Force
@svarukala
svarukala / VersionDocumentSets.cs
Created August 26, 2020 17:01
C# Sample to capture version of Document Sets using CSOM in SharePoint Online. It also lists out all the Document Set content type items along with the version information from a document library using the latest CSOM library released recently (version: 16.1.20317.12000 or above).
using Microsoft.SharePoint.Client;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security;
using System.Text;
using System.Threading.Tasks;
namespace CSOM.ConsoleApp.Sample
{
@svarukala
svarukala / Checkin-Files-Bulk-SPO.ps1
Created December 1, 2020 21:17
Force checkin the files across all sites and libraries or select few sites and libraries. Its configurable. This script applies to SPO.
#################################################
#Set $runconfig to one of the values below
#"checkinfiles" -->Runs the code across all the site collections and subwebs and checks in the files
#"checkinfilesselect" -->Runs the code on only those web urls that are supplied in the $websToProcess array
$runconfig = "checkinfilesselect" #"checkinfiles"
#Set $excludeLists array to library titles that needs to be excluded from processing
[String[]]$excludeLists = @('Excel Docs',
'Form Templates',
'Site Assets',
@svarukala
svarukala / Create-ServicePrincipalForPnPPowershell.ps1
Last active January 10, 2021 00:00
Creates the service principal for PnP PowerShell.
$PnPPowerShellAppId = "31359c7f-bd7e-475c-86db-fdb8c937548e"
az ad sp create --id $PnPPowerShellAppId
#The guid 00000003-0000-0000-c000-000000000000 corresponds to Microsoft Graph
az ad app permission grant --id $PnPPowerShellAppId --api 00000003-0000-0000-c000-000000000000 --scope User.Read.All,Group.ReadWrite.All
#The guid 00000003-0000-0ff1-ce00-000000000000 corresponds to SPO
az ad app permission grant --id $PnPPowerShellAppId --api 00000003-0000-0ff1-ce00-000000000000 --scope User.Read.All,Sites.FullControl.All