Skip to content

Instantly share code, notes, and snippets.

View neerajks77's full-sized avatar

Neeraj Kumar neerajks77

View GitHub Profile
@neerajks77
neerajks77 / CreateServicePrincipal.ps1
Last active February 4, 2024 13:20
This script will create the service principal in Azure AD and will be used for Azure Automation
#This function creates an Azure AD Service Principal
function CreateServicePrincipal {
param($username, $password)
$credproperties = @{
StartDate = Get-Date
EndDate = Get-Date -Year 2024
Password = $password
}
$cred= New-Object Microsoft.Azure.Commands.ActiveDirectory.PSADPasswordCredential -Property $credproperties
@neerajks77
neerajks77 / InitiateWatcherProcess.ps1
Last active February 4, 2024 13:47
This PowerShell is invoked when a new file is uploaded to the blob container. It gets the data and passes on to the other PowerShell for deployment of virtual machine. This approach has been taken to make the code more modular.
$Creds = Get-AutomationPSCredential -Name 'Creds'
$TenantID = Get-AutomationVariable -Name 'TenantID'
Connect-AzAccount -ServicePrincipal -Credential $Creds -Tenant $TenantID
$vResourceGroupname = "atcsl"
$vAutomationAccountName = "atcslautomation"
$vaStorageAccount = Get-AutomationVariable -Name "StorageAccount"
@neerajks77
neerajks77 / Get-TenantAppDetails.ps1
Created February 19, 2024 18:41
This PowerShell Automation Runbook script fetches the details of all the apps registered/created within Microsoft Entra ID (Azure AD).
<#################################################################################
Author: Neeraj Kumar
Description: This PowerShell Automation Runbook script fetches the details of all the apps registered/created within Microsoft Entra ID (Azure AD). The result is finally ouputted to a folder within SharePoint document library.
Please create all the variables with their values in the shared resources inside variables within Automation Account before use.
#################################################################################>
# Variables from Azure Automation Account
$Global:spSiteUrl = Get-AutomationVariable -Name 'SharePointSiteUrl'
$Global:spSiteName = Get-AutomationVariable -Name 'SharePointSiteName'
$Global:spLibraryName = Get-AutomationVariable -Name 'TenantDocumentLibraryName'
<#
Author: Neeraj Kumar
This script is used to create Exchange Online Monitoring and governance reports. Please create required variables under shared resources.
Also register an app within Microsoft Entra Id with API permissions for Exchange.ManageAsApp and give the role of Exchange Administrator.
CreatedDate : 24-Nov-2023
#>
$global:accessToken=$null
$tenantId = Get-AutomationVariable -Name 'TenantId'
@neerajks77
neerajks77 / Get-MSTeamsMonitoringReports.ps1
Created February 19, 2024 18:50
Extract the details of Microsoft Teams that includes Site Team and channel details, storage space, owner details, etc.
#####################################################################################
######Author: Neeraj Kumar
######Created: 28/09/2023
######Usage: Extract the details of Microsoft Teams that includes Site Team and channel details, storage space, owner details, etc.
#####################################################################################
# Variables from Azure Automation Account
$tenantId = Get-AutomationVariable -Name 'TenantId'
$clientId = Get-AutomationVariable -Name 'ClientId'
$clientSecret = Get-AutomationVariable -Name 'ClientSecret'
@neerajks77
neerajks77 / Get-OneDriveReports.ps1
Created February 19, 2024 18:53
This script is used to create OneDrive Monitoring and governance reports
#####################################################################################
######Author: Neeraj Kumar
######Created: 28/09/2023
######Usage: This script is used to create OneDrive Monitoring and governance reports. Please create required variables under shared resources.
#####################################################################################
$global:tenantId = Get-AutomationVariable -Name 'TenantId'
$global:clientId = Get-AutomationVariable -Name 'ClientId'
$global:clientSecret = Get-AutomationVariable -Name 'ClientSecret'
$global:certThumbprint = Get-AutomationVariable -Name 'CERT_THUMBPRINT'
@neerajks77
neerajks77 / Get-SharePointDetails.ps1
Created February 19, 2024 18:57
Extract the details of the SharePoint Online Sites that includes Site URL, Administrator Email, Group Email Id, Storage Space Used, and User Count
#####################################################################################
######Author: Neeraj Kumar
######Created: 28/09/2023
######Usage: Extract the details of the SharePoint Online Sites that includes Site URL, Administrator Email, Group Email Id, Storage Space Used, and User Count. Please create required variables under shared resources.
#####################################################################################
# Retrieve the stored username and password from Azure Automation variables
$adminUrl = Get-AutomationVariable -Name 'AdminURL'
$username = Get-AutomationVariable -Name 'SPAdminUsername'
$password = Get-AutomationVariable -Name 'SPAdminPassword' | ConvertTo-SecureString -AsPlainText -Force
@neerajks77
neerajks77 / Get-SharePointMonitoringReports.ps1
Last active February 19, 2024 19:01
Updated - Extract the details of the SharePoint Online Sites that includes Site URL, Administrator Email, Group Email Id, Storage Space Used, and User Count - Updated
#####################################################################################
######Author: Neeraj Kumar
######Created: 28/09/2023
######Usage: Extract the details of Microsoft SharePoint that includes Site Team and channel details, storage space, owner details, etc. Please create required variables under shared resources.
#####################################################################################
# Variables from Azure Automation Account
$tenantId = Get-AutomationVariable -Name 'TenantId'
$clientId = Get-AutomationVariable -Name 'ClientId'
$clientSecret = Get-AutomationVariable -Name 'ClientSecret'
@neerajks77
neerajks77 / M365LicenseUsageAnalysis.ps1
Created February 19, 2024 19:04
This script is used to create M265 License Usage Analysis reports
<#
Author: Neeraj Kumar
This script is used to create M265 License Usage Analysis reports. Please create required variables under shared resources.
Also register an app within Microsoft Entra Id with API permissions for Microsoft Graph usage.
CreatedDate : 24-Nov-2023
#>
$global:tenantId = Get-AutomationVariable -Name 'TenantId'