Skip to content

jameswh3/MW-Toolbox

Repository files navigation

MW-Toolbox

A collection of scripts and files that I use as part of my role as a Copilot Solution Engineer.

Environment Configuration

Setting Up Your .env File

Many scripts in this toolbox use environment variables for configuration. These variables can be set using a .env file in the root directory of the repository.

Creating Your .env File

  1. Copy the .env-example file to create your own .env file:

    Copy-Item .env-example .env
  2. Edit the .env file and replace the placeholder values with your actual configuration:

    # Multiple Scripts
    TENANT_ID=your-tenant-id-guid
    
    # Compliance scripts
    UPN=admin@yourtenant.onmicrosoft.com
    
    # Blob storage scripts
    STORAGE_ACCOUNT_NAME=yourstorageaccount
    RESOURCE_GROUP_NAME=your-resource-group
    CONTAINER_NAME=yourcontainer
    
    # And so on...
    
  3. The Menu.ps1 script will automatically load these variables when executed.

Available Environment Variables

The .env-example file includes configuration for:

  • Multiple Scripts: TENANT_ID
  • Compliance Scripts: UPN
  • Blob Storage Scripts: STORAGE_ACCOUNT_NAME, RESOURCE_GROUP_NAME, CONTAINER_NAME
  • Database Scripts: SQL_SERVER_NAME, SQL_RESOURCE_GROUP_NAME
  • Fabric Scripts: FABRIC_RESOURCE_GROUP_NAME, FABRIC_NAME
  • Power Platform Scripts: POWER_PLAT_CLIENT_ID, POWER_PLAT_CLIENT_SECRET, POWER_PLAT_TENANT_DOMAIN, POWER_PLAT_ORG_URL
  • Azure VM Scripts: AZURE_SUBSCRIPTION_ID, AZURE_VM_RESOURCE_GROUP_NAME
  • SharePoint Online Scripts: SHAREPOINT_ONLINE_CLIENT_ID, SHAREPOINT_ONLINE_CERTIFICATE_PATH, SHAREPOINT_ONLINE_CERTIFICATE_PASSWORD, SHAREPOINT_ONLINE_SITE_ID, SHAREPOINT_ONLINE_DRIVE_ID, SHAREPOINT_ONLINE_FOLDER_PATH, SHAREPOINT_ONLINE_ADMIN_URL, SHAREPOINT_ONLINE_SITE, SHAREPOINT_ONLINE_TENANT_DOMAIN, SHAREPOINT_ONLINE_LIBRARY
  • Salesforce Scripts: SF_AUTH_METHOD, SF_MY_DOMAIN, SF_API_BATCH_SIZE, SF_OUTPUT_DIR, SF_CLIENT_ID, SF_CLIENT_SECRET, SF_USERNAME, SF_PASSWORD, SF_SECURITY_TOKEN

Note: The .env file is included in .gitignore to prevent accidentally committing sensitive credentials to version control.

Root Scripts

Provides a reusable Import-DotEnv function that loads environment variables from a .env file into the current PowerShell process. Used by other scripts in the toolbox to load configuration without hard-coding credentials.

Import-DotEnv.ps1 Example

# Dot-source the function and load variables from .env in the current directory
. .\Import-DotEnv.ps1
Import-DotEnv

# Load from a specific path
Import-DotEnv -Path "C:\MyProject\.env"

Central configuration file that sets up environment variables and common configuration used by multiple scripts. Includes functionality to load settings from a .env file.

Menu.ps1 Example

# Load the configuration file
. .\Menu.ps1

# Environment variables will be loaded from .env file if present
# Variables include: UPN, TENANT_ID, STORAGE_ACCOUNT_NAME, etc.

Repository Tooling

Python script invoked by the pre-commit hook to strip all cell outputs and execution counts from staged Jupyter notebooks before they are committed. Prevents binary output data and tokens from being stored in version control.

One-time setup script that copies the pre-commit hook from the repo root into .git/hooks/. Run this after cloning the repository to activate automatic notebook output stripping on commit.

install-hooks.ps1 Example

# Run once after cloning
.\install-hooks.ps1

Git pre-commit hook (shell script) kept in version control so it can be shared across clones. Calls clear_notebook_outputs.py against all staged .ipynb files and re-stages the cleaned files automatically. Install it with install-hooks.ps1.

Azure

Retrieves all Azure App Registrations and displays their names and App IDs.

Get-AzureAppRegistrations.ps1 Example

# Run the script directly - it handles authentication and retrieval
.\Azure\Get-AzureAppRegistrations.ps1

Queries Azure Resource Graph to inventory agent-related resources across one or more subscriptions, including Bot Services, Azure AI/Cognitive Services accounts, Health Bots, and Machine Learning workspaces. Supports filtering by resource type and optional CSV export.

Get-AzureAgentInventory.ps1 Example

# Query all supported agent resources in the current Azure context
Get-AzureAgentInventory

# Export only Azure AI/Cognitive Services resources to CSV
Get-AzureAgentInventory -ResourceType CognitiveServices `
    -OutputPath "C:\temp\azure-agent-inventory.csv"

Retrieves information about files stored in Azure Blob Storage containers.

Get-AzureBlobFiles.ps1 Example

# Set your Azure storage parameters
$storageAccountName = "yourstorageaccount"
$containerName = "yourcontainer"

# Run the script
.\Azure\Get-AzureBlobFiles.ps1

Retrieves cost reports for Azure resource groups for a specified date range using Azure Cost Management API. Allows selection of resource groups and provides detailed cost breakdown by resource type.

Get-CostReportsByResourceGroups.ps1 Example

# Get cost reports for the last 7 days with resource group selection prompt
Get-AzureCostReportsByResourceGroups

# Get cost reports for a specific date range
Get-AzureCostReportsByResourceGroups -StartDate "2025-12-01" -EndDate "2025-12-17"

# Specify subscription and output directory
Get-AzureCostReportsByResourceGroups -SubscriptionId "your-subscription-id" `
    -OutputDirectory "C:\temp\CostReports"

Retrieves members of an Entra ID (Azure AD) group by name or email. Displays users, groups, and service principals with categorized output.

Get-EntraGroupMembers.ps1 Example

# Get members of a group by display name
.\Azure\Get-EntraGroupMembers.ps1 -GroupNameOrEmail "Marketing Team"

# Get members of a group by email
.\Azure\Get-EntraGroupMembers.ps1 -GroupNameOrEmail "marketing@contoso.com"

Configures network access rules for Azure Blob Storage accounts. Enables or disables public access and manages IP firewall rules.

Set-AzureBlobStorageAccess.ps1 Example

# Enable network restrictions and add current IP
Set-AzureBlobStorageAccess -ResourceGroupName "myResourceGroup" `
    -StorageAccountName "mystorageaccount" `
    -Enable

# Disable network restrictions
Set-AzureBlobStorageAccess -ResourceGroupName "myResourceGroup" `
    -StorageAccountName "mystorageaccount"

Configures Azure Key Vault public network access and firewall rules. Supports disabling public access entirely, allowing all networks, or restricting access to selected IP ranges including the caller's current public IP.

Set-AzureKeyVaultNetworkAccess.ps1 Example

# Restrict Key Vault access to selected networks and add your current public IP
Set-AzureKeyVaultNetworkAccess -ResourceGroupName "myResourceGroup" `
    -KeyVaultName "myKeyVault" `
    -Enable `
    -AddCurrentIP

# Disable all public network access
Set-AzureKeyVaultNetworkAccess -ResourceGroupName "myResourceGroup" `
    -KeyVaultName "myKeyVault" `
    -Disable

Configures Azure SQL Server access settings and firewall rules.

Set-AzureSQLServerAccess.ps1 Example

# Configure SQL Server access
Set-AzureSQLServerAccess -ServerName "yoursqlserver" `
    -ResourceGroupName "your-resource-group"

Manages the state (start/stop) of Microsoft Fabric capacities in Azure.

Set-FabricCapacityState.ps1 Example

# Set your Fabric capacity parameters
$subscriptionId = "your-subscription-id"
$resourceGroupName = "your-resource-group"
$capacityName = "your-fabric-capacity"
$state = "Active" # or "Paused"

# Run the script
.\Azure\Set-FabricCapacityState.ps1
Set-FabricCapacityState -ResourceGroupName $resourceGroupName `
        -FabricName $fabricName `
        -State "Active"

Starts Azure Virtual Machines across resource groups.

Start-AzureVMs.ps1 Example

# Run the script
.\Azure\Start-AzureVMs.ps1

Start-AzureVMs -ResourceGroupName "<your resource group>" `
    -SubscriptionId "<your subscription id>"

Stops Azure Virtual Machines across resource groups.

Stop-AzureVMs.ps1 Example

# Stop VMs in a resource group
Stop-AzureVMs -ResourceGroupName "<your resource group>" `
    -SubscriptionId "<your subscription id>"

Requests Just-In-Time (JIT) VM access for all VMs defined in a resource group's JIT network access policy. Automatically detects the caller's current public IP as the allowed source address. Requires the Az.Security module.

Request-AzVMJitAccess.ps1 Example

# Request JIT access for all VMs in a resource group (auto-detects public IP)
Request-AzVMJitAccess -ResourceGroupName "rg-sharepoint-farm"

# Specify subscription, duration, and source IP explicitly
Request-AzVMJitAccess -ResourceGroupName "rg-sharepoint-farm" `
    -SubscriptionId "your-subscription-id" `
    -DurationHours 2 `
    -SourceAddressPrefix "203.0.113.10"

A Swagger 2.0/OpenAPI definition file for the Azure Maps Render API. This file describes the API endpoints for generating static map images with customizable pins, paths, and styling. Can be used to create a custom Power Platform connector to the Azure Maps API.

azure-maps-render-api.swagger.yaml Example

Import this file into Power Platform to create a custom connector, or use a Swagger UI viewer to visualize and interact with the API.

A Jupyter Notebook demonstrating how to authenticate with Azure and call the Azure Maps Render API to generate static map images. Works in conjunction with the azure-maps-render-api.swagger.yaml definition file.

azure-maps-render.ipynb Example

Open the notebook in VS Code and run cells sequentially. Ensure your .env file contains the required Azure Maps credentials.

Compliance

Retrieves all retention policies and their associated rules from Microsoft 365 Compliance Center.

Get-AllRetentionPoliciesAndRules.ps1 Example

# Set your parameters
$upn = "admin@yourdomain.com"

# Run the script
.\Compliance\Get-AllRetentionPoliciesAndRules.ps1

Searches the unified audit log and retrieves results for specified date ranges.

Get-AuditLogResults.ps1 Example

# Set your parameters
$startDate = "2025-06-01"
$endDate = "2025-06-24"

# Run the script
.\Compliance\Get-AuditLogResults.ps1

Creates a compliance content search in Microsoft 365, waits for it to complete, then exports the results. Supports searching specific mailboxes or all mailboxes using a KQL query. Monitors both the search and export operations until completion.

New-ContentSearch.ps1 Example

# Search a specific mailbox for emails with "confidential" in the subject
New-ContentSearch -SearchName "Investigation001" `
    -Query "subject:confidential" `
    -Mailbox "user@contoso.com"

# Search all mailboxes for Q4 2025 content
New-ContentSearch -SearchName "Q4Search" `
    -Query "date>=2025-10-01" `
    -Mailbox "All" `
    -UserPrincipalName "admin@contoso.com"

Copilot

Retrieves audit log entries for Copilot bot creation events.

Get-CopilotCreationAuditLogItems.ps1 Example

# Set your parameters
$upn = "admin@yourdomain.com"
$startDate = "2025-06-01"
$endDate = "2025-06-24"

# Run the script
.\Copilot\Get-CopilotCreationAuditLogItems.ps1

Retrieves audit log entries for Copilot interaction events.

Get-CopilotInteractionAuditLogItems.ps1 Example

# Run the script with parameters
.\Copilot\Get-CopilotInteractionAuditLogItems.ps1 -StartDate '2025-06-01' `
    -EndDate '2025-06-30' `
    -UserPrincipalName 'admin@yourdomain.com' `
    -OutputFile 'c:\temp\copilotinteractionauditlog.csv' `
    -Append

A Jupyter Notebook for interacting with a Copilot retrieval API.

copilot_retrieval_api.ipynb Example

Open the notebook in a compatible environment like VS Code to see the documented steps for API interaction.

A Swagger/OpenAPI definition file for a Copilot retrieval API. This file describes the API endpoints, parameters, and responses & can be used to create a custom Power Platform connector to this API.

copilot-retrieval-api.swagger.yaml Example

Use a Swagger UI viewer to visualize and interact with the API defined in this file.

A Jupyter Notebook for retrieving Microsoft 365 Copilot usage reports via Microsoft Graph API using application permissions. Demonstrates authentication with client credentials and accessing Reports.Read.All API endpoints.

copilot_usage_reports_api.ipynb Example

Open the notebook in VS Code or Jupyter. Ensure your .env file contains:

  • CopilotReportAPIPythonClient_Id
  • CopilotReportAPIPythonClient_Secret
  • CopilotAPIPythonClient_Tenant

Grant Reports.Read.All application permission in your Entra App Registration.

A Jupyter Notebook for retrieving Microsoft Teams meeting insights and transcripts using Microsoft Graph API with delegated user permissions. Demonstrates how to access meeting transcripts and AI-generated insights.

meeting_insights_api.ipynb Example

Open the notebook in VS Code or Jupyter. Configure your Entra App Registration with delegated permissions:

  • User.Read
  • Calendars.Read
  • OnlineMeetings.Read
  • OnlineMeetingTranscript.Read.All
  • OnlineMeetingAiInsight.Read.All

Enable public client flow in your App Registration authentication settings.

A Jupyter Notebook for listing Copilot packages available in the tenant catalog via the Microsoft Graph beta API (/copilot/admin/catalog/packages). Supports optional OData $filter parameters to filter by supported host, element type, or last modified date. Displays results as both raw JSON and a formatted summary table.

copilot_packages_api.ipynb Example

Open the notebook in VS Code. Ensure your .env file contains:

  • CopilotAPIPythonClient_Id
  • CopilotAPIPythonClient_Tenant

Grant CopilotPackages.ReadWrite.All delegated permission (with admin consent) in your Entra App Registration. Enable public client flow in your App Registration authentication settings.

Retrieves audit log entries for Copilot sharing events and activities.

Get-CopilotSharingAuditLogItems.ps1 Example

# Set your parameters
$upn = "admin@yourdomain.com"
$startDate = "2025-06-01"
$endDate = "2025-06-24"

# Run the script
.\Copilot\Get-CopilotSharingAuditLogItems.ps1 -StartDate $startDate `
    -EndDate $endDate `
    -UserPrincipalName $upn `
    -OutputFile 'c:\temp\copilotsharingauditlog.csv'

Entra

Retrieves detailed information about an Entra ID user.

Get-EntraUserInfo.ps1 Example

# Set the user UPN
$upn = "user@yourdomain.com"

# Run the script
.\Entra\Get-EntraUserInfo.ps1

Gets license information for Entra ID users.

Get-EntraUserLicenseInfo.ps1 Example

# Set the user UPN
$upn = "user@yourdomain.com"

# Run the script
.\Entra\Get-EntraUserLicenseInfo.ps1

Creates a self-signed certificate for Entra (Azure AD) app registration authentication. Generates both PFX (with private key) and CER (public key) files with configurable validity period. Optionally installs the certificate to CurrentUser or LocalMachine certificate store.

New-EntraAppCertificate.ps1 Example

# Create certificate with default settings (exports to C:\temp)
.\Entra\New-EntraAppCertificate.ps1

# Create certificate for specific app and install to CurrentUser store
.\Entra\New-EntraAppCertificate.ps1 -SubjectName "CN=SharePoint Scripts" -InstallToStore

# Create certificate with custom validity and install to LocalMachine (requires admin)
.\Entra\New-EntraAppCertificate.ps1 -SubjectName "CN=MyApp" `
    -ValidityYears 3 `
    -InstallToStore `
    -StoreLocation LocalMachine

# Specify custom export location and certificate name
.\Entra\New-EntraAppCertificate.ps1 -SubjectName "CN=MyApp" `
    -ExportPath "C:\Certificates" `
    -CertificateName "MyAppCert"

Updates the User Principal Name (UPN) for Azure AD users.

Update-AzureADUserUPN.ps1 Example

# Set the old and new UPN values
Update-AADUserUPN -originalUpn "user@olddomain.com" `
    -newUpn "user@newdomain.com" `
    -applyChanges `
    -logFolder 'c:\temp\upnupdatelog.csv'

Misc

Analyzes system performance metrics and provides detailed performance insights.

Get-SystemPerformanceAnalysis.ps1 Example

# Run the script to analyze system performance
.\Misc\Get-SystemPerformanceAnalysis.ps1

Inventories all PowerShell modules installed via PowerShellGet/PSGallery, checks for available updates, and optionally applies them. Displays a formatted report showing installed vs. latest versions and a summary of update status. Untrusted repository prompts are automatically suppressed since the user is making an explicit approval decision within the script itself.

When run interactively, each outdated module presents a streamlined prompt:

  • Y — update this module, continue prompting for remaining modules
  • A — update this module and all remaining modules without further prompting
  • N — skip this module
  • Q — quit the update loop

Update-InstalledModules.ps1 Example

# Show inventory and prompt before updating each outdated module (Y/A/N/Q per module)
.\Misc\Update-InstalledModules.ps1

# Display inventory report only — no changes made
.\Misc\Update-InstalledModules.ps1 -InventoryOnly

# Automatically update all outdated modules without prompting
.\Misc\Update-InstalledModules.ps1 -UpdateAll

# Update all modules in the AllUsers scope, excluding specific modules
.\Misc\Update-InstalledModules.ps1 -UpdateAll -Scope AllUsers -ExcludeModules @('Az', 'AzureAD')

# Dry-run to see what would be updated without applying changes
.\Misc\Update-InstalledModules.ps1 -UpdateAll -WhatIf

Imports .rdp files from a source folder into an existing Remote Desktop Connection Manager (RDCMan) .rdg file, creating or updating server entries under a dedicated group. Reads usernames and domain information from each .rdp file and writes them into the RDCMan logonCredentials element. Configured via .env variables: RDCMAN_SOURCE_PATH, RDCMAN_DESTINATION_PATH, RDCMAN_RDG_FILENAME, RDCMAN_GROUP_NAME.

Update-RDCManFile.ps1 Example

# Import .rdp files using .env defaults
.\Misc\Update-RDCManFile.ps1

# Preview changes without writing to the .rdg file
.\Misc\Update-RDCManFile.ps1 -WhatIf

# Specify paths explicitly
.\Misc\Update-RDCManFile.ps1 -SourcePath "C:\RDPFiles" `
    -DestinationPath "C:\Users\you\Documents" `
    -RdgFileName "mylab.rdg" `
    -GroupName "Lab Servers"

A Jupyter Notebook that reads a CSV file and generates an individual Word document for each row. Column names become section headings, and the configured title column is used to name each output file.

csv-to-word-documents.ipynb Example

Open the notebook in VS Code, update CSV_FILE_PATH, OUTPUT_DIR, and TITLE_COLUMN, then run all cells to generate the Word documents.

A streamlined version of the CSV-to-Word workflow for quickly converting structured CSV data into one Word document per record.

csv-to-word-documents-simplified.ipynb Example

Open the notebook in VS Code, update the input CSV and output folder paths, and run the cells in order.

A Jupyter Notebook for extracting calendar event details from PST files for meeting analysis. Includes a Windows-friendly pywin32 approach and guidance for using readpst when needed.

pst_calendar_extraction.ipynb Example

Open the notebook in VS Code, update the PST file path and export settings, then run the cells sequentially to extract and analyze calendar events.

MsGraph

Retrieves online meeting recordings for a specific user within a date range using Microsoft Graph.

Get-OnlineMeetingRecordings.ps1 Example

# Set your parameters
$clientId = "your-app-registration-id"
$tenantId = "your-tenant-id"
$cert = Get-ChildItem -Path "Cert:\CurrentUser\My" | Where-Object {$_.Subject -like "*YourCertName*"}
$meetingOrganizerUserId = "user@yourdomain.com"

# Run the script
.\MsGraph\Get-OnlineMeetingRecordings.ps1

Generates comprehensive Microsoft 365 usage and activity reports using Microsoft Graph.

M365Reporting.ps1 Example

# Set your reporting parameters
$tenantId = "your-tenant-id"
$clientId = "your-app-registration-id"

# Run the script
.\MsGraph\M365Reporting.ps1

Power-Platform

Adds an application user to Power Platform environment(s) using the Power Platform CLI. Supports adding to a single environment or all environments in a tenant with a specified security role. Requires Power Platform CLI (pac) to be installed.

Add-AppUserViaCLI.ps1 Example

# Add app user to a specific environment
.\Power-Platform\Add-AppUserViaCLI.ps1 -AppId "12345678-1234-1234-1234-123456789012" `
    -OrgUrl "https://org.crm.dynamics.com"

# Add app user to ALL environments in the tenant
.\Power-Platform\Add-AppUserViaCLI.ps1 -AppId "12345678-1234-1234-1234-123456789012" `
    -AllEnvironments

# Use custom role and skip authentication
.\Power-Platform\Add-AppUserViaCLI.ps1 -AppId "12345678-1234-1234-1234-123456789012" `
    -OrgUrl "https://org.crm.dynamics.com" `
    -Role "Basic User" `
    -SkipAuth

Converts conversation transcript data from Power Platform to human-readable format, reconstructing chronological conversations between users and bots.

ConvertFrom-AgentTranscript.ps1 Example

# Convert transcript data to readable format
.\Power-Platform\ConvertFrom-AgentTranscript.ps1 -InputFile "C:\temp\conversationtranscripts.txt" `
    -OutputFile "C:\temp\readable_transcripts.txt"

Runs a diagnostic workflow for Copilot Studio custom agent and Microsoft Defender for Cloud Apps integration issues. Checks the app registration, service principal state, admin consent, conditional access impact, and recent sign-in activity, then writes the results to a diagnostic log file.

Diagnose-CopilotStudioMDCA.ps1 Example

# Run the diagnostic for a specific tenant and app registration
.\Power-Platform\Diagnose-CopilotStudioMDCA.ps1 -AppRegistrationId "12345678-1234-1234-1234-123456789012" `
    -TenantId "your-tenant-id" `
    -OutputPath "C:\temp\DiagnosticOutput.txt"

Retrieves Copilot Studio message consumption for Power Platform environments over a reporting period using the Licensing API. Useful for reviewing billed and non-billed credits by environment and feature.

Get-AgentMessageConsumptionReport.ps1 Example

# Load the script and review the collected consumption data
. .\Power-Platform\Get-AgentMessageConsumptionReport.ps1

# Export the results if needed
$consumption | Export-Csv -Path "C:\temp\agent-message-consumption.csv" -NoTypeInformation

Retrieves information about all data policy connectors in the Power Platform tenant.

Get-AllDataPolicyConnectorInfo.ps1 Example

# Run the script directly - it handles authentication and data retrieval
Get-AllDataPolicyConnectorInfo | Export-Csv -Path "C:\temp\PowerPlatformDataPolicyConnectors.csv" -NoTypeInformation -Force

Retrieves all billing policies for a Power Platform tenant via the Power Platform Licensing REST API. Handles pagination automatically.

Get-BillingPlansViaAPI.ps1 Example

# Get all billing policies
Get-BillingPlansViaAPI -ClientId "your-client-id" `
    -ClientSecret "your-secret" `
    -TenantDomain "contoso.onmicrosoft.com"

# Limit results per page
Get-BillingPlansViaAPI -ClientId "your-client-id" `
    -ClientSecret "your-secret" `
    -TenantDomain "contoso.onmicrosoft.com" `
    -Top 10

Gets bot components information using Power Platform APIs.

Get-BotComponentsViaAPI.ps1 Example

# Set your environment parameters
$clientId="<your client id>"
$clientSecret="<your client secret>"
$orgUrl="<your org>.crm.dynamics.com"
$tenantDomain="<your tenant domain>.onmicrosoft.com"

# Run the script
Get-BotComponentsViaAPI -ClientId $clientId `
    -ClientSecret $clientSecret `
    -OrgUrl $orgUrl `
    -TenantDomain $tenantDomain `
    -FieldList $fieldList

Retrieves conversation transcripts from Power Platform bots via API within a specified date range.

Get-ConversationTranscriptsViaAPI.ps1 Example

# Set your environment parameters
$clientId = "<your client id>"
$clientSecret = "<your client secret>"
$orgUrl = "<your org>.crm.dynamics.com"
$tenantDomain = "<your tenant domain>.onmicrosoft.com"
$endDate = (Get-Date).ToString("yyyy-MM-dd")
$startDate = (Get-Date).AddDays(-30).ToString("yyyy-MM-dd")

# Run the script
Get-ConversationTranscriptsViaAPI -ClientId $clientId `
    -ClientSecret $clientSecret `
    -OrgUrl $orgUrl `
    -TenantDomain $tenantDomain `
    -StartDate $startDate `
    -EndDate $endDate `
    -FieldList "content,createdon,conversationtranscriptid,_bot_conversationtranscriptid_value,metadata" `
    | Export-Csv -Path "C:\temp\conversation-transcripts.csv" -NoTypeInformation

Retrieves Copilot agents information via Power Platform APIs.

Get-CopilotAgentsViaAPI.ps1 Example

# Run the script

Get-CopilotAgentsViaAPI -ClientId "<your client id>" `
    -ClientSecret "<your client secret>" `
    -OrgUrl "<your org>.crm.dynamics.com" `
    -TenantDomain "<your domain>.onmicrosoft.com" `
    -FieldList "botid,componentidunique,applicationmanifestinformation,name,configuration,createdon,publishedon,_ownerid_value,_createdby_value,solutionid,modifiedon,_owninguser_value,schemaname,_modifiedby_value,_publishedby_value,authenticationmode,synchronizationstatus,ismanaged" `
    | Out-File "c:\temp\bots.txt"

Retrieves a comprehensive list of all Copilot agents and their components from all Power Platform environments.

Get-CopilotsAndComponentsFromAllEnvironments.ps1 Example

# Run the script to get all copilots and components
.\Power-Platform\Get-CopilotsAndComponentsFromAllEnvironments.ps1 | Export-Csv -Path "C:\temp\AllCopilotsAndComponents.csv" -NoTypeInformation

Retrieves all Power Apps and their connections within the tenant.

Get-PowerAppsAndConnections.ps1 Example

# Run the script to get all Power Apps and their connections
.\Power-Platform\Get-PowerAppsAndConnections.ps1 | Export-Csv -Path "C:\temp\PowerAppsAndConnections.csv" -NoTypeInformation

Retrieves detailed information about all Power Platform environments.

Get-PowerPlatformEnvironmentInfo.ps1 Example

# Run the script to get environment information
.\Power-Platform\Get-PowerPlatformEnvironmentInfo.ps1 | Export-Csv -Path "C:\temp\PowerPlatformEnvironments.csv" -NoTypeInformation

Generates usage reports for Power Platform services.

Get-PowerPlatformUsageReports.ps1 Example

# Run the script to generate usage reports
.\Power-Platform\Get-PowerPlatformUsageReports.ps1 -ReportType "ActiveUsers" -OutputDirectory "C:\temp\UsageReports"

Retrieves tenant-level settings for Power Platform via API.

Get-PowerPlatTenantSettingsViaAPI.ps1 Example

# Set your environment parameters
$clientId = "<your client id>"
$clientSecret = "<your client secret>"
$tenantDomain = "<your tenant domain>.onmicrosoft.com"

# Run the script
.\Power-Platform\Get-PowerPlatTenantSettingsViaAPI.ps1 -ClientId $clientId -ClientSecret $clientSecret -TenantDomain $tenantDomain

Retrieves users from a Power Platform environment via API.

Get-UsersViaAPI.ps1 Example

# Set your environment parameters
$clientId = "<your client id>"
$clientSecret = "<your client secret>"
$orgUrl = "<your org>.crm.dynamics.com"
$tenantDomain = "<your tenant domain>.onmicrosoft.com"

# Run the script
.\Power-Platform\Get-UsersViaAPI.ps1 -ClientId $clientId -ClientSecret $clientSecret -OrgUrl $orgUrl -TenantDomain $tenantDomain

Changes the owner of a Power App in a Power Platform environment. Automatically installs required Power Apps administration modules if not present.

Set-NewPowerAppOwner.ps1 Example

.\Power-Platform\Set-NewPowerAppOwner.ps1 -AppName "cd304785-1a9b-44c3-91a8-c4174b59d835" `
    -EnvironmentName "de6b35af-dd3f-e14d-80ff-7a702c009100" `
    -AppOwner "7eda74de-bd8b-ef11-ac21-000d3a5a9ee8"

SharePoint

Creates an inventory of SharePoint on-premises farm components and configuration.

Inventory-SPFarm.ps1 Example

# Set your SharePoint farm parameters
Inventory-SPFarm `
    -LogFilePrefix "Test_" `
    -DestinationFolder "d:\temp" `
    -InventoryFarmSolutions `
    -InventoryFarmFeatures `
    -InventoryWebTemplates `
    -InventoryTimerJobs `
    -InventoryWebApplications `
    -InventorySiteCollections `
    -InventorySiteCollectionAdmins `
    -InventorySiteCollectionFeatures `
    -InventoryWebPermissions `
    -InventoryWebs `
    -InventorySiteContentTypes `
    -InventoryWebFeatures `
    -InventoryLists `
    -InventoryWebWorkflowAssociations `
    -InventoryListContentTypes `
    -InventoryListWorkflowAssociations `
    -InventoryContentTypeWorkflowAssociations `
    -InventoryContentDatabases `
    -InventoryListFields `
    -InventoryListViews `
    -InventoryWebParts

Snowflake

A Jupyter Notebook lab for configuring Snowflake OAuth with Azure/Entra ID. It automates most of the setup work, including app registration creation or reuse, app role assignment, token generation, Snowflake SQL generation, and optional direct execution when admin credentials are provided.

snowflake_oauth_lab_setup.ipynb Example

Open the notebook in VS Code and run the cells sequentially. Sign in first with az login, and optionally populate .env with SNOWFLAKE_ACCOUNT, SNOWFLAKE_ADMIN_USER, and SNOWFLAKE_ADMIN_PASSWORD if you want the generated SQL to be applied directly in Snowflake.

SQL

SQL query that converts a table schema to JSON format, useful for documentation and schema analysis. Can be used in agent instructions to tell the agent how the tables are structured.

SharePoint-Online

Adds users as owners to a SharePoint site using certificate-based authentication.

Add-OwnersToSharePointSite.ps1 Example

# Set your parameters
$siteUrl = "https://contoso.sharepoint.com/sites/yoursite"
$ownerEmails = @("user1@contoso.com", "user2@contoso.com")
$clientId = "your-app-registration-id"
$tenant = "contoso.onmicrosoft.com"
$certificatePath = "C:\path\to\certificate.pfx"

# Run the function
Add-OwnersToSharePointSite -SiteUrl $siteUrl `
    -OwnerEmails $ownerEmails `
    -ClientId $clientId `
    -Tenant $tenant `
    -CertificatePath $certificatePath

Converts SharePoint Site ID, Web ID, and List ID GUIDs into the base64-encoded Drive ID format used by the Microsoft Graph API. Useful for constructing Graph API calls that reference SharePoint document libraries.

ConvertTo-SharePointDriveId.ps1 Example

# Convert GUIDs to a Graph API Drive ID
ConvertTo-SharePointDriveId `
    -siteId "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" `
    -webId  "yyyyyyyy-yyyy-yyyy-yyyy-yyyyyyyyyyyy" `
    -listId "zzzzzzzz-zzzz-zzzz-zzzz-zzzzzzzzzzzz"

Returns the Microsoft Graph Drive ID for one or all document libraries in a SharePoint site. Useful when you need the drive identifier for Graph API calls or automation.

Get-SharePointDriveId.ps1 Example

# Get all document library Drive IDs for a SharePoint site
.\SharePoint-Online\Get-SharePointDriveId.ps1 -SharePointUrl "https://contoso.sharepoint.com/sites/MySite"

# Get the Drive ID for a specific library
.\SharePoint-Online\Get-SharePointDriveId.ps1 -SharePointUrl "https://contoso.sharepoint.com/sites/MySite" `
    -LibraryName "Documents"

Inventories SharePoint Embedded containers across the tenant, including storage, owners, status, and owning application metadata. Supports optional CSV export for reporting.

Get-SPOEmbeddedInventory.ps1 Example

# Review all SharePoint Embedded containers in the tenant
Get-SPOEmbeddedInventory -SPOAdminUrl "https://contoso-admin.sharepoint.com"

# Export the inventory to CSV
Get-SPOEmbeddedInventory -SPOAdminUrl "https://contoso-admin.sharepoint.com" `
    -OutputPath "C:\temp\spe-inventory.csv"

Generates reports on Copilot agent usage and activities in SharePoint Online.

Get-CopilotAgentReport.ps1 Example

$spoAdminUrl="https://<your tenant>-admin.sharepoint.com"

.\SharePoint-Online\Get-CopilotAgentReport.ps1

Retrieves Microsoft Graph delta query results for tracking changes in SharePoint Online.

Get-GraphDeltaQueryResults.ps1 Example

# Run the script to get delta query results
.\SharePoint-Online\Get-GraphDeltaQueryResults.ps1

Retrieves audit log entries for SharePoint agent creation events.

Get-SharePointAgentCreationAuditLogItems.ps1 Example

# Set your parameters
$upn = "admin@yourdomain.com"
$startDate = "2025-06-01"
$endDate = "2025-06-24"

# Run the script
.\SharePoint-Online\Get-SharePointAgentCreationAuditLogItems.ps1

Retrieves audit log entries for SharePoint agent interaction events.

Get-SharePointAgentInteractionAuditLogItems.ps1 Example

# Set your parameters
$upn = "admin@yourdomain.com"
$startDate = "2025-06-01"
$endDate = "2025-06-24"

# Run the script
.\SharePoint-Online\Get-SharePointAgentInteractionAuditLogItems.ps1

Gets metadata properties of a file in a SharePoint document library using PnP PowerShell.

Get-SharePointFileProperties.ps1 Example

# Get file properties
.\SharePoint-Online\Get-SharePointFileProperties.ps1 -SiteUrl "https://contoso.sharepoint.com/sites/team" `
    -LibraryUrl "/sites/team/Shared Documents" `
    -FileName "Document.docx"

Creates a complete demo environment with hub sites, regional sites, and project sites with proper associations.

New-DemoProjectHubSites.ps1 Example

# Run the script to create demo project hub structure
.\SharePoint-Online\New-DemoProjectHubSites.ps1

Creates demo project plan documents with random team assignments and tasks.

New-DemoProjectPlanDocs.ps1 Example

# Requires ImportExcel and PSWriteWord modules
# Run the script to generate project plan documents
.\SharePoint-Online\New-DemoProjectPlanDocs.ps1

Creates SharePoint Online Hub Sites using PnP.PowerShell, with optional parent hub site association.

New-HubSites.ps1 Example

# Create hub sites
$siteUrls = @("https://contoso.sharepoint.com/sites/Hub1", "https://contoso.sharepoint.com/sites/Hub2")
$parentHubSiteId = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"

# Run the script
.\SharePoint-Online\New-HubSites.ps1 -SiteUrls $siteUrls -ParentHubSiteId $parentHubSiteId

Creates new OneDrive sites for users in SharePoint Online.

New-OneDriveSites.ps1 Example

# Set your parameters
$usernames = @("user1@domain.com", "user2@domain.com", "user3@domain.com")
$batchSize = 200
$tenantName = "yourtenant"

# Run the script function
New-OneDriveSites -usernames $usernames -batchsize $batchSize -tenantname $tenantName

Configures SharePoint Online organizational asset libraries for Office templates and images.

Set-SPOOrgAssetLibrary.ps1 Example

# Update the tenant variable with your tenant name
$tenant = "contoso"

# Run the script to configure organizational asset libraries
.\SharePoint-Online\Set-SPOOrgAssetLibrary.ps1

Uploads documents to specified SharePoint sites and libraries using an input array.

Upload-Documents.ps1 Example

# Define documents to upload
$documents = @(
    @{
        FilePath = "C:\temp\ProjectA Plan.docx"
        SiteUrl = "https://contoso.sharepoint.com/sites/ProjectA"
        Library = "Shared Documents"
    },
    @{
        FilePath = "C:\temp\ProjectB Plan.docx"
        SiteUrl = "https://contoso.sharepoint.com/sites/ProjectB"
        Library = "Shared Documents"
    }
)

# Run the script
.\SharePoint-Online\Upload-Documents.ps1

Teams

Retrieves all Teams meeting policies and their configuration settings.

Get-AllTeamsMeetingPolicies.ps1 Example

# Run the script to get all Teams meeting policies
.\Teams\Get-AllTeamsMeetingPolicies.ps1

Retrieves all Microsoft Teams using Microsoft Graph API.

Get-AllTeamsViaGraph.ps1 Example

# Set your Graph API parameters
$clientId = "your-app-registration-id"
$tenantId = "your-tenant-id"
$cert = Get-ChildItem -Path "Cert:\CurrentUser\My" | Where-Object {$_.Subject -like "*YourCertName*"}

# Run the script
.\Teams\Get-AllTeamsViaGraph.ps1

Retrieves messages from specified Teams channels.

Get-ChannelMessages.ps1 Example

# Run the script
.\Teams\Get-ChannelMessages.ps1

Gets Teams and their membership information.

Get-TeamsAndMembers.ps1 Example

# Run the script
.\Teams\Get-TeamsAndMembers.ps1

Retrieves all Teams that a specific user is a member of.

Get-UserTeams.ps1 Example

# Set the user parameters
$userId = "user@yourdomain.com"
$tenantId = "your-tenant-id"

# Run the script
.\Teams\Get-UserTeams.ps1

Creates new channels in a specified Microsoft Team.

New-Channels.ps1 Example

# Set your parameters
$teamId = "<your team id>"
$channelNames = @("General Discussion", "Project Updates", "Resources")

# Run the script
.\Teams\New-Channels.ps1 -TeamId $teamId -ChannelNames $channelNames

Creates new Microsoft Teams with specified names and optional owners/members.

New-Teams.ps1 Example

# Set your parameters
$teamNames = @("Project Alpha", "Project Beta", "Project Gamma")
$owner = "admin@yourdomain.com"
$members = @("user1@yourdomain.com", "user2@yourdomain.com")

# Run the script
.\Teams\New-Teams.ps1 -TeamNames $teamNames -Owner $owner -Members $members

Configures moderation settings for Teams channels.

Set-ChannelModerationSettings.ps1 Example

# Set your channel parameters
$clientId="<your client id>"
$teamId = "<your team id>"
$channelId = "<your-channel-id>"
$tenantDomain = "yourdomain.onmicrosoft.com"
$moderationSettings = @{
    "moderationSettings"= @{
        "userNewMessageRestriction"= "moderators"
        "replyRestriction" = "authorAndModerators"
        "allowNewMessageFromBots" = "false"
        "allowNewMessageFromConnectors"= "false"
    }
}

# Run the script
.\Teams\Set-ChannelModerationSettings.ps1

Blocks a Teams app, making it unavailable to all users by modifying the app permission policy.

Set-TeamsAppAvailability.ps1 Example

# Block a Teams app using its App ID
.\Teams\Set-TeamsAppAvailability.ps1 -AppId "12345678-1234-1234-1234-123456789012"

# Block app with a custom policy name
.\Teams\Set-TeamsAppAvailability.ps1 -AppId "12345678-1234-1234-1234-123456789012" `
    -PolicyName "CustomPolicy"

Viva

Enables Microsoft Viva services for a tenant, including Viva Topics, Connections, Learning, and Insights, and configures the SharePoint home site used for Viva Connections.

Enable-VivaFeatures.ps1 Example

# Enable Viva services for the tenant
.\Viva\Enable-VivaFeatures.ps1 -AdminUrl "https://contoso-admin.sharepoint.com" `
    -HomeSiteUrl "https://contoso.sharepoint.com/sites/Home" `
    -UserScope "All"

Salesforce

A Jupyter Notebook that dynamically generates realistic synthetic Salesforce Account, Opportunity, and Case records for testing, development, and demo purposes, then inserts them directly into Salesforce via the REST API. Records are relationally linked — Opportunities and Cases reference valid Account IDs returned from the Account inserts. Supports both Username/Password and OAuth 2.0 Client Credentials authentication. Data can also be exported locally as CSV, JSON, or a multi-sheet Excel workbook without inserting into Salesforce.

salesforce_synthetic_data_generator.ipynb Example

Open the notebook in VS Code. Ensure your .env file contains the Salesforce credentials for your chosen auth method:

Option A — Username/Password:

  • SF_AUTH_METHOD=password
  • SF_USERNAME, SF_PASSWORD, SF_SECURITY_TOKEN
  • SF_DOMAINlogin for production, test for sandbox

Option B — Client Credentials (recommended):

  • SF_AUTH_METHOD=client_credentials
  • SF_CLIENT_ID, SF_CLIENT_SECRET
  • SF_MY_DOMAIN — your org's My Domain hostname (Setup → My Domain)

Run cells sequentially. Section 8 inserts records into Salesforce; Section 9 exports data locally without inserting.

About

A collection of scripts that I use as a Modern Work SME at Microsoft

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors