Skip to content

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

Notifications You must be signed in to change notification settings

jameswh3/MW-Toolbox

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

61 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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_SITE_ID, SHAREPOINT_ONLINE_DRIVE_ID, SHAREPOINT_ONLINE_FOLDER_PATH

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

Root Scripts

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.

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

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 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>"

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.

Compliance

Performs a compliance content search and exports the results.

ContentSearch.ps1 Example

# Set your search parameters
$upn="admin@domain.com"
$complianceSearchName = "MyContentSearch"
$mailbox = "<mailbox email address>"
$startDate="2025-02-20"
$endDate="2025-02-22"
$kql="Subject:`"`" AND sent>=$startDate AND sent<=$endDate"

# Run the script
.\Compliance\ContentSearch.ps1

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

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.

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

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"

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

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

SharePoint

Performs an inventory of a SharePoint farm. This is for on-premises SharePoint environments.

Inventory-SPFarm.ps1 Example

# Run the script to start the inventory process
.\SharePoint\Inventory-SPFarm.ps1 -FarmConfigDatabase "SP_Config"

SharePoint-Online

Adds owners to a SharePoint Online site.

Add-OwnersToSharePointSite.ps1 Example

# Set your parameters
$siteUrl = "https://yourtenant.sharepoint.com/sites/YourSite"
$ownerEmails = "user1@yourdomain.com", "user2@yourdomain.com"

# Run the script
.\SharePoint-Online\Add-OwnersToSharePointSite.ps1 -SiteUrl $siteUrl -OwnerEmails $ownerEmails

Converts SharePoint site information to Drive IDs for Microsoft Graph API usage.

ConvertTo-SharePointDriveId.ps1 Example

# Set the SharePoint site URL

ConvertTo-SharePointDriveId -siteId "<site GUID>" `
    -webId "<web GUID>" `
    -listId "<list GUID>"

Generates a report on Copilot agents in SharePoint Online.

Get-CopilotAgentReport.ps1 Example

# Run the script to generate the report
.\SharePoint-Online\Get-CopilotAgentReport.ps1 -OutputDirectory "C:\temp\Reports"

Retrieves results from a Microsoft Graph delta query, which can be used to track changes to SharePoint Online resources.

Get-GraphDeltaQueryResults.ps1 Example

# Run the script with your delta query parameters
.\SharePoint-Online\Get-GraphDeltaQueryResults.ps1 -DeltaLink "your_delta_link"

Retrieves audit log items related to the creation of SharePoint agents.

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 -StartDate $startDate -EndDate $endDate -UserPrincipalName $upn

Retrieves audit log items for SharePoint agent interactions.

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 -StartDate $startDate -EndDate $endDate -UserPrincipalName $upn

Retrieves properties of files in a SharePoint Online document library.

Get-SharePointFileProperties.ps1 Example

# Set your parameters
$siteUrl = "https://yourtenant.sharepoint.com/sites/YourSite"
$libraryName = "Documents"

# Run the script
.\SharePoint-Online\Get-SharePointFileProperties.ps1 -SiteUrl $siteUrl -LibraryName $libraryName

Creates new hub sites for a demo project in SharePoint Online.

New-DemoProjectHubSites.ps1 Example

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

Creates new project plan documents for a demo in SharePoint Online.

New-DemoProjectPlanDocs.ps1 Example

# Run the script to create the demo documents
.\SharePoint-Online\New-DemoProjectPlanDocs.ps1

Creates new hub sites in SharePoint Online.

New-HubSites.ps1 Example

# Run the script to create new hub sites
.\SharePoint-Online\New-HubSites.ps1 -HubSiteNames "HR", "IT", "Finance"

Provisions new OneDrive for Business sites for users.

New-OneDriveSites.ps1 Example

# Set the user emails
$userEmails = "user1@yourdomain.com", "user2@yourdomain.com"

# Run the script
.\SharePoint-Online\New-OneDriveSites.ps1 -UserEmails $userEmails

Designates a SharePoint Online document library as an organization assets library.

Set-SPOOrgAssetLibrary.ps1 Example

# Set your parameters
$libraryUrl = "https://yourtenant.sharepoint.com/sites/branding/logos"

# Run the script
.\SharePoint-Online\Set-SPOOrgAssetLibrary.ps1 -LibraryUrl $libraryUrl

Uploads documents to a SharePoint Online document library.

Upload-Documents.ps1 Example

# Set your parameters
$siteUrl = "https://yourtenant.sharepoint.com/sites/YourSite"
$libraryName = "Documents"
$sourceFolder = "C:\temp\Upload"

# Run the script
.\SharePoint-Online\Upload-Documents.ps1 -SiteUrl $siteUrl -LibraryName $libraryName -SourceFolder $sourceFolder

SQL

A SQL script that converts a table schema to a JSON format.

TableSchemaToJSON.sql Example

-- Execute this script in your SQL management tool against your database.
-- It will output the schema of a specified table as JSON.

Teams

Retrieves all Microsoft Teams meeting policies.

Get-AllTeamsMeetingPolicies.ps1 Example

# Run the script to get all meeting policies
.\Teams\Get-AllTeamsMeetingPolicies.ps1 | Export-Csv -Path "C:\temp\TeamsMeetingPolicies.csv" -NoTypeInformation

Retrieves a list of all teams in the organization using Microsoft Graph.

Get-AllTeamsViaGraph.ps1 Example

# Run the script to get all teams
.\Teams\Get-AllTeamsViaGraph.ps1

Retrieves messages from a specific Microsoft Teams channel.

Get-ChannelMessages.ps1 Example

# Set your parameters
$teamId = "your-team-id"
$channelId = "your-channel-id"

# Run the script
.\Teams\Get-ChannelMessages.ps1 -TeamId $teamId -ChannelId $channelId

Retrieves all teams and their members.

Get-TeamsAndMembers.ps1 Example

# Run the script to get teams and members
.\Teams\Get-TeamsAndMembers.ps1 | Export-Csv -Path "C:\temp\TeamsAndMembers.csv" -NoTypeInformation

Retrieves the teams that a specific user is a member of.

Get-UserTeams.ps1 Example

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

# Run the script
.\Teams\Get-UserTeams.ps1 -UserPrincipalName $upn

Creates new channels in a Microsoft Team.

New-Channels.ps1 Example

# Set your parameters
$teamId = "your-team-id"
$channelNames = "General", "Announcements", "Project-X"

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

Creates new teams in Microsoft Teams.

New-Teams.ps1 Example

# Run the script to create new teams
.\Teams\New-Teams.ps1 -TeamNames "Marketing Team", "Sales Team"

Configures moderation settings for a Microsoft Teams channel.

Set-ChannelModerationSettings.ps1 Example

# Set your parameters
$teamId = "your-team-id"
$channelId = "your-channel-id"

# Run the script
.\Teams\Set-ChannelModerationSettings.ps1 -TeamId $teamId -ChannelId $channelId -EnableModeration $true

Retrieves information about Power Platform Environments.

Get-PowerPlatTenantSettingsViaAPI.ps1 Example

#Modify the following variables with your own values
    $clientId="<your client id>"
    $clientSecret="<your client secret>"
    $tenantDomain="<your tenant>.onmicrosoft.com>"

    .\Power-Platform\Get-PowerPlatTenantSettingsViaAPI.ps1

Retrieves user information via Power Platform APIs.

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
Get-UsersViaAPI -ClientId $clientId `
    -ClientSecret $clientSecret `
    -OrgUrl $orgUrl `
    -TenantDomain $tenantDomain `
    -FieldList "systemuserid,fullname,internalemailaddress,domainname,isdisabled,accessmode,createdon" `
    | Export-Csv -Path "C:\temp\users.csv" -NoTypeInformation

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

# Set the Power App ownership
.\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

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.

Swagger Files

OpenAPI/Swagger specification for the Copilot Retrieval API, for use when building custom connectors for Power Platform.

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

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"

About

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

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published