How microsoft/powerbi-powershell works
Project type and purpose
• This is a CLI/library project: a suite of PowerShell modules (MicrosoftPowerBIMgmt.*) implemented in C#/.NET Standard, published to the PowerShell Gallery.
• Purpose: provide PowerShell cmdlets that authenticate to and call the Power BI REST API for Admin, Capacities, Data, Profile, Reports, and Workspaces operations.
File structure
• Top-level “src” folder with:
• Common libraries:
– Commands.Common (base cmdlet abstractions, logging, configuration)
– Common.Abstractions (interfaces for auth, storage, logging, cmdlets)
– Common.Api (HTTP clients for each API surface: Workspaces, Datasets, Reports, etc.)
– Common.Authentication (implementations: DeviceCode, ServicePrincipal, Windows)
– Common.Client (PowerShell-specific cmdlet hosting and client factory)
– Common.Dependencies (NuGet-shipped dependencies)
• Modules (under Modules/*/Commands.*): Admin, Capacities, Data, Profile, Reports, Workspaces — each produces a separate PowerShell module.
• Build and packaging: build, scripts, Directory.Build.*, GitHub workflows, examples.
Core components
a. PowerShell Host
– Users issue cmdlets (e.g. Get-PowerBIWorkspace)
b. Module Layer
– Each module references:
• Commands.Common for base cmdlet behavior
• Common.Client for cmdlet‐level wiring
• Common.Api for API operations
• Common.Authentication to obtain tokens
c. Common Libraries
– Commands.Common
– Common.Abstractions
– Common.Client
d. HTTP/Network
– HttpClient
e. External Services
– Azure AD (token endpoint)
– Power BI REST API endpoints
f. Build & Packaging Tooling (side-panel)
– Scripts (Build.ps1, Test.ps1, PublishModules.ps1)
– GitHub Actions (CI/CD workflows)
Architectural patterns and principles
• Layered architecture: Host → Modules → Common libraries → External services
• Dependency Injection via factory interfaces in Common.Abstractions
• Single Responsibility: separate cmdlet implementation from HTTP/API code and from authentication
• Extensibility: new modules can reuse common libraries
Relevant technologies/frameworks
• .NET Standard (class libraries compiled to DLLs)
• PowerShell SDK (PSModule manifests .psd1, formatting .ps1xml)
• HttpClient & JSON serialization
• PowerShell Gallery publishing (NuGet.config, .nuspec, scripts)