Skip to content

Instantly share code, notes, and snippets.

$PolicyNameID = "Enter your Policy Name ID here"
$ApplicationId = "xxxxx"
$ClientSecret = "xxxxx"
$TenantId = "xxxxx"
# Connect to PowerApps and Microsoft Graph
# Ensure you have the required modules installed: Microsoft.PowerApps.Administration.PowerShell and Microsoft.Graph
Add-PowerAppsAccount -ApplicationId $ApplicationId -ClientSecret $ClientSecret -TenantID $TenantId
#Requires -Modules Microsoft.Graph
# Install the module. (You need admin on the machine.)
# Install-Module Microsoft.Graph
# Set Static Variables
$TenantID="Enter your tenant ID here"
$AutomationAccountDisplayname ="Enter your Automation Account Display Name here"
# Define dynamic variables
# Set environment variables or edit the corresponding values here.
$endpoint = "XXXXXXXXXXXXXXXXX"
$api_key = "XXXXXXXXXXXXXXXXX"
$api_version = 'preview'
$headers = @{
"api-key" = $api_key
"Content-Type" = "application/json"
}
param
(
[Parameter(Mandatory=$false)]
[object] $WebhookData
)
$threshold = 5
# Jira authentication
$Text = "[email protected]:$(Get-AutomationVariable -Name 'JIRA')"
# This script will get all VMs with the guest OS "Windows Server" and send the details to a webhook URL in JSON format.
$VMs = get-vm | Where-Object{$_.guest -match "Windows Server"} |Select-Object -Property Name,Guest,CreateDate
# Convert the VM details to JSON format
$body = $VMs | ConvertTo-Json
$webhookURI = "Enter your webhook URL here"
# Send the JSON data to the webhook URL for the Azure Automation runbook
# Alexander Holmeset
# Version 1.0
# This script is designed to extract sensitivity labels from files in SharePoint document libraries in one tenant and apply them to the same files in another tenant.
# It uses Microsoft Graph API to interact with SharePoint and sensitivity labels.
# The script connects to two different tenants using app registrations and retrieves files from SharePoint document libraries.
# App regstiration permissions source: Directory.Read.All, Files.Read.All, Sites.Read.All and InformationProtectionPolicy.Read.All
# App regstiration permissions target: Directory.Read.All, Files.ReadWrite.All, Sites.Read.All and InformationProtectionPolicy.Read.All
# Parameters for the app registration source tenant
$ClientId = "xxxxxxx"
# Parameters for the app registration
$ClientId = "xxxxx"
$TenantId = "xxxxx"
$ClientSecret = "xxxxx"
$NumberOfMajorVersionsToKeep = 20
$TotalSizeAllVersions = 0
$TotalSizeReducedVersions = 0
#Threshold for the last activity
$threshold = 50
$CopilotLicenseGroupID = "xxxxx-xxx-xxxx-xxx"
# Connect to Microsoft Graph using the Tenant ID and Client Secret Credential
Connect-MgGraph -identity
#Requires -Modules Microsoft.Graph
# Install the module. (You need admin on the machine.)
# Install-Module Microsoft.Graph
# Set Static Variables
$TenantID="Enter your Tenant ID"
$LogicAppDisplayname = "CopilotActivityCheck"
# Define dynamic variables
$ServicePrincipalFilter = "displayName eq '$($LogicAppDisplayname)'"
#Requires -Modules Microsoft.Graph
# Install the module. (You need admin on the machine.)
# Install-Module Microsoft.Graph
# Set Static Variables
$TenantID="Enter your Tenant ID"
$LogicAppDisplayname = "NewCopilotUserEmail"
# Define dynamic variables
$ServicePrincipalFilter = "displayName eq '$($LogicAppDisplayname)'"