Skip to content

Latest commit

 

History

History
 
 

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

MicrosoftFabricMgmt PowerShell Module

Overview

MicrosoftFabricMgmt is an enterprise-grade PowerShell module providing comprehensive automation and management capabilities for Microsoft Fabric environments. Built with PowerShell best practices and modern development standards, this module delivers a robust, production-ready interface to the entire Microsoft Fabric REST API ecosystem.

NOTE: This module is currently only compatible with PowerShell version 7 and later. PowerShell 5.1 support could be added if there is sufficient demand.

🚀 Key Features

  • 355+ Cmdlets - Complete coverage of Microsoft Fabric REST API
  • 58 Resource Types - Manage Lakehouses, Warehouses, Notebooks, Pipelines, ML Models, Eventstreams, Graph Models, and more
  • Multiple Auth Methods - User Principal, Service Principal, and Managed Identity support
  • Enterprise Ready - Built-in retry logic, comprehensive error handling, and PSFramework logging
  • Intelligent Output Formatting - Automatic GUID-to-name resolution with smart caching for readable results
  • API Validated - All endpoints verified against official Microsoft Fabric REST API specifications
  • Cross-Platform - PowerShell 5.1+ and PowerShell 7+ compatible
  • Fully Documented - Complete help documentation and examples for every cmdlet
  • Modern Architecture - Centralized helper functions eliminate code duplication and improve maintainability

💪 What You Can Do

Workspace Management

  • Create, update, and manage workspaces
  • Configure role-based access control (RBAC)
  • Assign workspaces to capacities and domains
  • Provision workspace identities

Data Platform

  • Manage Lakehouses, Warehouses, and SQL Endpoints
  • Orchestrate Data Pipelines and Dataflows
  • Configure Mirrored Databases
  • Automate OneLake shortcuts and data access policies

Analytics & BI

  • Deploy and manage Semantic Models, Reports, and Dashboards
  • Create KQL Databases, Dashboards, and Querysets
  • Configure Eventhouses and Real-Time Intelligence
  • Manage Paginated Reports

Data Engineering

  • Deploy Notebooks and Spark Job Definitions
  • Configure Environments and custom Spark pools
  • Manage ML Experiments and Models
  • Orchestrate Apache Airflow Jobs

Streaming & Real-Time

  • Create and manage Eventstreams
  • Configure destinations and sources
  • Control stream operations (pause, resume, suspend)

Administration

  • Tenant-level settings and capacity management
  • Domain administration and workspace assignments
  • Connection and gateway management
  • Deployment pipeline automation
  • Admin API: Tenant-wide workspace and item visibility
  • Audit user access across the entire tenant
  • Restore deleted workspaces

Data Integration

  • Snowflake Database connections for cross-platform analytics
  • Cosmos DB Database integration for NoSQL workloads
  • Graph Models for relationship-based data analysis

Quick Start

Installation

From PowerShell Gallery (Recommended)

As with all PowerShell modules, you can either clone the repository and import the module manually, or use the PowerShell Gallery to install it directly. We recommend using the PowerShell Gallery for easier updates and management.

# Install from PowerShell Gallery
Install-Module -Name MicrosoftFabricMgmt

You can find the module on the PowerShell Gallery here: MicrosoftFabricMgmt on PSGallery

You can update the module at any time using:

# Update the module
Update-Module -Name MicrosoftFabricMgmt

Manual Installation

# Install required dependencies
$RequiredModules = @(
    @{ Name = 'PSFramework'; MinimumVersion = '5.0.0' }
    @{ Name = 'Az.Accounts'; MinimumVersion = '5.0.0' }
    @{ Name = 'Az.Resources'; MinimumVersion = '6.15.1' }
    @{ Name = 'MicrosoftPowerBIMgmt'; MinimumVersion = '1.2.1111' }
)

foreach ($module in $RequiredModules) {
    if (-not (Get-Module -ListAvailable -Name $module.Name -ErrorAction SilentlyContinue)) {
        Install-Module -Name $module.Name -MinimumVersion $module.MinimumVersion -Repository PSGallery -Scope CurrentUser
    }
}

# Clone the repository
git clone https://github.com/microsoft/fabric-toolbox.git
cd fabric-toolbox

You can also download the ZIP file from GitHub and extract it. You can even use this function Rob created to only extract the tools\MicrosoftFabricMgmt folder.

# Import the module
Import-Module .\output\module\MicrosoftFabricMgmt\*\MicrosoftFabricMgmt.psd1

Authentication Setup

Before using any cmdlets, authenticate to Microsoft Fabric using Set-FabricApiHeaders. The module supports three authentication methods:

Option 1: User Principal (Interactive)

Best for: Interactive sessions, development, testing

# Authenticate with your user account
Set-FabricApiHeaders -TenantId "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"

# This will prompt for interactive authentication via your browser
# Your credentials are cached for the sessions

Fabric Headers

Option 2: Service Principal (Automated)

Best for: CI/CD pipelines, automation scripts, scheduled tasks

# Define your Service Principal credentials
$tenantId = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
$appId = "yyyyyyyy-yyyy-yyyy-yyyy-yyyyyyyyyyyy"
$appSecret = "your-client-secret-value"

# Convert secret to SecureString
$secureAppSecret = $appSecret | ConvertTo-SecureString -AsPlainText -Force

# Authenticate
Set-FabricApiHeaders -TenantId $tenantId -AppId $appId -AppSecret $secureAppSecret

Service Principal Setup Requirements:

  1. Register an App in Azure AD
  2. Grant Fabric API permissions to the App
  3. Assign appropriate Fabric roles (Admin, Member, Contributor, Viewer)
  4. Enable Service Principal access in Fabric admin settings

Option 3: Managed Identity (Azure Resources)

Best for: Azure VMs, Azure Functions, Azure Automation, Azure DevOps

# Authenticate using the system-assigned or user-assigned managed identity
Set-FabricApiHeaders -TenantId "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" -UseManagedIdentity

# For user-assigned managed identity, specify the client ID
$managedIdentityClientId = "zzzzzzzz-zzzz-zzzz-zzzz-zzzzzzzzzzzz"
Set-FabricApiHeaders -TenantId $tenantId -UseManagedIdentity -ManagedIdentityId $managedIdentityClientId

Managed Identity Setup Requirements:

  1. Enable Managed Identity on your Azure resource
  2. Grant Fabric API permissions via Azure RBAC
  3. Assign appropriate Fabric workspace roles

Your First Commands

Once authenticated, you're ready to manage your Fabric environment:

# List all workspaces you have access to
Get-FabricWorkspace

# Get a specific workspace by name
Get-FabricWorkspace -WorkspaceName "My Analytics Workspace"

Fabric Workspace

# Create a new workspace
$newWorkspace = New-FabricWorkspace -WorkspaceName "Dev Environment" -WorkspaceDescription "Development workspace for analytics"

# Assign the workspace to a capacity
Assign-FabricWorkspaceCapacity -WorkspaceId $newWorkspace.id -CapacityId "your-capacity-id"

# List all lakehouses in a workspace
Get-FabricLakehouse -WorkspaceId $newWorkspace.id

# Create a lakehouse
New-FabricLakehouse -WorkspaceId $newWorkspace.id -LakehouseName "SalesData" -LakehouseDescription "Sales analytics lakehouse"

Fabric Lakehouse

# List notebooks in a workspace
Get-FabricNotebook -WorkspaceId $newWorkspace.id

# Get workspace role assignments
Get-FabricWorkspaceRoleAssignment -WorkspaceId $newWorkspace.id

# Add a user to the workspace
Add-FabricWorkspaceRoleAssignment -WorkspaceId $newWorkspace.id -PrincipalId "user@contoso.com" -Role "Contributor"

Common Scenarios

📊 Deploy a Complete Analytics Environment

# 1. Create workspace
$workspace = New-FabricWorkspace -WorkspaceName "Sales Analytics" -WorkspaceDescription "Q4 Sales Analysis"

# 2. Assign to capacity
Add-FabricWorkspaceCapacity -WorkspaceId $workspace.id -CapacityId $capacityId

# 3. Create lakehouse for data storage
$lakehouse = New-FabricLakehouse -WorkspaceId $workspace.id -LakehouseName "SalesData"

# 4. Create warehouse for analytics
$warehouse = New-FabricWarehouse -WorkspaceId $workspace.id -WarehouseName "SalesWarehouse"

# 5. Deploy notebooks for data processing
New-FabricNotebook -WorkspaceId $workspace.id -NotebookName "Data Processing"

# 6. Create data pipeline for orchestration
New-FabricDataPipeline -WorkspaceId $workspace.id -DataPipelineName "Sales ETL Pipeline"

# 7. Add team members
Add-FabricWorkspaceRoleAssignment -WorkspaceId $workspace.id -PrincipalId "analyst@contoso.com" -Role "Contributor"

🔄 Automate Environment Promotion

# Get items from Dev workspace
$devWorkspace = Get-FabricWorkspace -WorkspaceName "Dev"
$notebooks = Get-FabricNotebook -WorkspaceId $devWorkspace.id
$pipelines = Get-FabricDataPipeline -WorkspaceId $devWorkspace.id

# Create in Production workspace
$prodWorkspace = Get-FabricWorkspace -WorkspaceName "Production"

foreach ($notebook in $notebooks) {
    $definition = Get-FabricNotebookDefinition -WorkspaceId $devWorkspace.id -NotebookId $notebook.id
    New-FabricNotebook -WorkspaceId $prodWorkspace.id -NotebookName $notebook.displayName
    Update-FabricNotebookDefinition -WorkspaceId $prodWorkspace.id -NotebookId $newNotebook.id -NotebookDefinition $definition
}

🛡️ Audit Workspace Access

# Get all workspaces
$workspaces = Get-FabricWorkspace

# Audit role assignments
$auditReport = foreach ($workspace in $workspaces) {
    $assignments = Get-FabricWorkspaceRoleAssignment -WorkspaceId $workspace.id

    foreach ($assignment in $assignments) {
        [PSCustomObject]@{
            WorkspaceName = $workspace.displayName
            UserEmail = $assignment.UserPrincipalName
            DisplayName = $assignment.DisplayName
            Role = $assignment.Role
            Type = $assignment.Type
        }
    }
}

# Export to CSV
$auditReport | Export-Csv -Path "FabricWorkspaceAudit_$(Get-Date -Format 'yyyyMMdd').csv" -NoTypeInformation

📊 Intelligent Output Formatting

The module includes smart output formatting that automatically makes results more readable and actionable by:

Automatic Name Resolution

Instead of displaying raw GUIDs, the module automatically resolves IDs to human-readable names:

  • Capacity IDs → Capacity display names
  • Workspace IDs → Workspace display names

Example - Without Formatting:

id                                   displayName          type      workspaceId                          capacityId
--                                   -----------          ----      -----------                          ----------
a1b2c3d4-e5f6-1234-5678-9abcdef01234 Sales Lakehouse      Lakehouse f9e8d7c6-b5a4-9876-5432-1fedcba98765 c4d5e6f7...

Example - With Smart Formatting:

Capacity Name        Workspace Name       Item Name           Type      ID
-------------        --------------       ---------           ----      --
Premium Capacity P1  Sales Analytics      Sales Lakehouse     Lakehouse a1b2c3d4-e5f6...
Premium Capacity P1  Sales Analytics      ETL Notebook        Notebook  b2c3d4e5-f6a7...
Premium Capacity P2  Marketing Workspace  Campaign Data       Warehouse c3d4e5f6-a7b8...

Performance with Smart Caching

Name resolutions are cached for optimal performance:

  • First lookup: ~200ms (API call)
  • Cached lookup: <1ms (~200x faster!)
  • Cache persists across sessions
  • Automatic cache management

Clear Cache When Needed

After renaming capacities or workspaces, clear the cache to fetch updated names:

# Clear all cached name resolutions
Clear-FabricNameCache -Force

# Output: Successfully cleared 42 cached name resolution(s)

Consistent Display Format

All objects display with consistent column priority:

  1. Capacity Name
  2. Workspace Name
  3. Item Name
  4. Item Type
  5. Additional properties...

Learn More: See the complete Output Formatting Guide for details on format views, caching behavior, and troubleshooting.


Prerequisites

PowerShell Version

  • PowerShell 5.1 or later
  • PowerShell 7+ (recommended for cross-platform support)

Required Modules

The following modules are automatically installed as dependencies:

Module Minimum Version Purpose
PSFramework 5.0.0 Configuration management and logging
Az.Accounts 5.0.0 Azure authentication
Az.Resources 6.15.1 Azure resource management
MicrosoftPowerBIMgmt 1.2.1111 Power BI integration

Permissions Required

For User Principal:

  • Appropriate Fabric workspace roles (Admin, Member, Contributor, or Viewer)
  • Tenant-level permissions for admin operations

For Service Principal:

  • App must be enabled in Fabric admin portal
  • Fabric API delegated scopes granted
  • Workspace roles assigned

For Managed Identity:

  • Identity must have Fabric API permissions
  • Workspace roles assigned via RBAC

Architecture & Design

Modern PowerShell Best Practices

This module implements industry-standard PowerShell development practices:

  • DRY Principle - Centralized helper functions eliminate 1,000+ lines of duplicate code
  • Approved Verbs - All cmdlets use PowerShell approved verbs
  • Proper Scoping - Module-scoped variables prevent global namespace pollution
  • Natural Output - Leverages PowerShell pipeline for idiomatic code
  • Comprehensive Error Handling - Try/catch blocks with detailed error messages
  • PSFramework Integration - Consistent logging and configuration management
  • API Validation - All endpoints verified against official Fabric REST API specs

Centralized Helper Functions

The module uses core helper functions that provide:

  1. Invoke-FabricAuthCheck - Consistent authentication validation across all cmdlets
  2. New-FabricAPIUri - Standardized API endpoint construction with query parameters
  3. Select-FabricResource - Consistent resource filtering and type decoration for Get-* cmdlets
  4. Add-FabricTypeName - PSTypeName decoration for custom formatting
  5. Invoke-FabricAPIRequest - Centralized API calls with pagination, retry logic, and LRO support

Benefits:

  • Bug fixes in one place automatically benefit all 294 cmdlets
  • Consistent behavior across entire module
  • Easier testing and maintenance
  • Enhanced retry logic with exponential backoff
  • Automatic pagination handling via continuation tokens
  • Built-in Long Running Operation (LRO) support

Built-in Resilience

  • Automatic Retry Logic - Handles transient failures (429, 503, 504 status codes)
  • Exponential Backoff - Intelligent retry delays with jitter
  • Respects Rate Limits - Honors Retry-After headers from API
  • Comprehensive Logging - Debug, verbose, and error logging via PSFramework

Documentation

Cmdlet Help

Every cmdlet includes comprehensive help documentation:

# Get help for any cmdlet
Get-Help Get-FabricWorkspace -Full
Get-Help Set-FabricApiHeaders -Examples
Get-Help New-FabricLakehouse -Parameter LakehouseName

# List all available cmdlets
Get-Command -Module MicrosoftFabricMgmt

# Find cmdlets by resource type
Get-Command -Module MicrosoftFabricMgmt -Name *Lakehouse*
Get-Command -Module MicrosoftFabricMgmt -Name *Notebook*

Resource Coverage

The module provides comprehensive coverage of Microsoft Fabric resources:

📦 58 Resource Types (Click to expand)
Resource Type Cmdlets Description
Admin 8 Tenant-wide administration
Anomaly Detector 6 Anomaly detection operations (Preview)
Apache Airflow Job 6 Airflow job management
Capacity 1 Capacity operations
Connections 6 Connection and gateway management
Copy Job 6 Data copy operations
Cosmos DB Database 6 Cosmos DB integration
Dashboard 1 Dashboard operations
Data Pipeline 4 Pipeline orchestration
Dataflow 6 Dataflow operations and parameters
Datamart 1 Datamart management
Digital Twin Builder 6 Digital twin building operations (Preview)
Digital Twin Builder Flow 6 Digital twin flow management (Preview)
Domain 11 Domain administration
Environment 13 Spark environment management
Event Schema Set 6 Event schema management (Preview)
Eventstream 17 Real-time data streaming
Eventhouse 6 Real-time analytics platform
External Data Share 2 Data sharing operations
Folder 5 Workspace folder management
Graph Model 8 Graph-based data modeling and queries
Graph Query Set 6 Graph query operations (Preview)
GraphQL API 6 GraphQL API operations
KQL Dashboard 6 KQL dashboard management
KQL Database 6 KQL database operations
KQL Queryset 6 KQL query management
Labels 2 Item labeling
Lakehouse 9 Lakehouse operations, table management
Managed Private Endpoint 3 Private endpoint management
Map 6 Map item management (Preview)
Mirrored Azure Databricks Catalog 6 Databricks catalog mirroring
Mirrored Database 10 Database mirroring
Mirrored Warehouse 1 Warehouse mirroring
ML Experiment 4 ML experiment tracking
ML Model 4 Machine learning model management
Mounted Data Factory 6 Data Factory integration
Notebook 8 Notebook deployment and management
OneLake 6 OneLake shortcuts and security
Ontology 6 Ontology management (Preview)
Operations Agent 6 Operations agent management (Preview)
Paginated Reports 2 Paginated report management
Reflex 6 Reflex item management
Report 6 Power BI report operations
Semantic Model 6 Semantic model management
Sharing Links 2 Sharing link management
Snowflake Database 6 Snowflake integration
Spark 9 Spark pool and settings
Spark Job Definition 8 Spark job orchestration
SQL Database 6 SQL Database management
SQL Endpoints 3 SQL endpoint management
Tags 4 Item tagging
Tenant 8 Tenant-level settings
User Data Function 6 User data function operations (Preview)
Users 1 User operations
Utils 10 Utility functions
Variable Library 5 Variable management
Warehouse 9 Warehouse operations and snapshots
Workspace 14 Workspace management, RBAC, capacity assignment

Total: 355+ Cmdlets across 58 resource types


Advanced Usage

Pipeline Integration

All cmdlets support PowerShell pipeline operations:

# Get all lakehouses and export their metadata
Get-FabricWorkspace |
    ForEach-Object {
        Get-FabricLakehouse -WorkspaceId $_.id
    } |
    Export-Csv -Path "AllLakehouses.csv" -NoTypeInformation

# Filter workspaces and list their notebooks
Get-FabricWorkspace |
    Where-Object { $_.displayName -like "Dev*" } |
    ForEach-Object {
        Get-FabricNotebook -WorkspaceId $_.id |
            Select-Object @{N='Workspace';E={$_.displayName}}, displayName, id
    }

Error Handling

try {
    $workspace = New-FabricWorkspace -WorkspaceName "Production" -ErrorAction Stop
    Write-Host "Workspace created: $($workspace.id)"
}
catch {
    Write-Error "Failed to create workspace: $_"
    # Handle error appropriately
}

Logging and Diagnostics

The module uses PSFramework for comprehensive logging:

# Enable verbose logging
$VerbosePreference = "Continue"
Get-FabricWorkspace

# View PSFramework message log
Get-PSFMessage -Last 50

# Configure logging to file
Set-PSFLoggingProvider -Name logfile -FilePath "C:\Logs\Fabric.log" -Enabled $true

Contributing

We welcome contributions! This project is part of the microsoft/fabric-toolbox repository.

Development Setup

# Clone the repository
git clone https://github.com/microsoft/fabric-toolbox.git
cd fabric-toolbox/tools/MicrosoftFabricMgmt

# Install development dependencies
.\build.ps1 -ResolveDependency

# Build the module
.\build.ps1 -Tasks build

# Run tests
.\build.ps1 -Tasks test

Module Build System

The module uses Sampler, a modern PowerShell module scaffolding framework:

  • Build: .\build.ps1 -Tasks build
  • Test: .\build.ps1 -Tasks test
  • Clean: .\build.ps1 -Tasks clean
  • Pack: .\build.ps1 -Tasks pack

Support & Resources

Documentation

Community

Getting Help

# Get help for any cmdlet
Get-Help <CmdletName> -Full

# List all cmdlets in the module
Get-Command -Module MicrosoftFabricMgmt

# Find cmdlets by keyword
Get-Command -Module MicrosoftFabricMgmt | Where-Object { $_.Name -like "*Lakehouse*" }

License

This project is licensed under the MIT License. See the LICENSE file for details.


Changelog

Version 1.0.5 - Pipeline Support and Cache Performance

Latest Release - Full Pipeline Support and Smarter Caching

  • ✅ Full pipeline support for all 46 Remove-* functions — pipe Get-Fabric* output directly to Remove-Fabric*
  • ✅ Fixed [Alias('id')] bindings so Get-FabricWorkspace | Remove-FabricWorkspace and similar patterns work correctly
  • ✅ Eliminated repeated API calls for unresolvable IDs — fallback results are now cached, not re-fetched
  • ✅ Cross-cache population: resolving a workspace name also caches its capacity ID (and vice versa), halving API calls
  • ✅ Changed "not found" resolve messages from Warning to Verbose — quieter output in mixed-capacity environments

Version 1.0.4 - New Resource Types and Admin API

Previous Release - New Resource Types and Admin API

  • ✅ 295+ cmdlets (51 new functions added)
  • ✅ 6 new resource types: Graph Model, Snowflake Database, Cosmos DB Database, Dataflow, SQL Database, Admin
  • ✅ Admin API for tenant-wide visibility into workspaces, items, and user access
  • ✅ Full pipeline support with ValueFromPipelineByPropertyName
  • ✅ Intelligent output formatting with PSTypeName decoration

Version 1.0.0 - Major Modernization Release

  • ✅ 244+ cmdlets covering all major Fabric resource types
  • ✅ Centralized helper functions (1,000+ lines of duplicate code eliminated)
  • ✅ Enhanced retry logic with exponential backoff
  • ✅ All endpoints validated against official API specifications
  • ✅ PowerShell 5.1 and 7+ compatibility
  • ✅ Comprehensive error handling and logging
  • ✅ Fixed workspace role assignment URI construction bug
  • ✅ Implemented PowerShell community best practices

For detailed release notes, see CHANGELOG.md.


Acknowledgments

Authors & Contributors:

  • Tiago Balabuch
  • Jess Pomfret
  • Rob Sewell

Special Thanks:

  • Microsoft Fabric Team for the comprehensive REST API
  • PowerShell Community for best practices and guidance
  • PSFramework Team for the excellent logging and configuration framework

Built with ❤️ by the Microsoft Fabric community
GitHubMicrosoft Fabric DocsPowerShell Gallery