FabricTools v0.33.0 Public Preview

Connect-FabricAccount

Connects to the Fabric WebAPI.

Syntax

Connect-FabricAccount [[-TenantId] <guid>] [[-ServicePrincipalId] <guid>]
 [[-ServicePrincipalSecret] <securestring>] [[-Credential] <pscredential>] [-Reset]
 [-UseDeviceAuthentication] [-WhatIf] [-Confirm] [<CommonParameters>]

Description

Connects to the Fabric WebAPI by using the cmdlet Connect-AzAccount. This function retrieves the authentication token for the Fabric API and sets up the headers for API calls. User sign-in uses interactive authentication by default. Use -UseDeviceAuthentication if the interactive broker or browser cannot be used.

Examples

Example 1

Connects to the stated Tenant with existing credentials

Connect-FabricAccount -TenantId '12345678-1234-1234-1234-123456789012'

Example 2

Connects as a service principal using a PSCredential object. The username is the service principal's application ID.

$credential = Get-Credential -UserName '<service-principal-app-id>' -Message 'Enter the service principal client secret'
Connect-FabricAccount -TenantId '<tenant-id>' -Credential $credential

Example 3

Connects as Service Principal using AppId and secret

$TenantID               = '12345678-1234-1234-1234-123456789012'
$ServicePrincipalId     = '4cbbe76e-1234-1234-0000-ffffffffffff'
$ServicePrincipalSecret = 'xyz'

$ServicePrincipalSecretSecure = ($ServicePrincipalSecret | ConvertTo-SecureString -AsPlainText -Force)
Connect-FabricAccount -TenantId $TenantID -ServicePrincipalId $ServicePrincipalId -ServicePrincipalSecret $ServicePrincipalSecretSecure -Reset

Example 4

Connects using device code authentication (useful in terminals such as Warp where the account picker cannot render)

Connect-FabricAccount -UseDeviceAuthentication

Example 5

Connects as Service Principal using credential object

$TenantID               = '12345678-1234-1234-1234-123456789012'
$ServicePrincipalId     = '4cbbe76e-1234-1234-0000-ffffffffffff'
$ServicePrincipalSecret = 'xyz'

$ServicePrincipalSecretSecure = ($ServicePrincipalSecret | ConvertTo-SecureString -AsPlainText -Force)
$credential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $ServicePrincipalId, $ServicePrincipalSecretSecure
Connect-FabricAccount -TenantId $TenantID -Credential $credential -Verbose -Reset

Parameters

NameTypeReq.Pos.PipelineDescription
-Confirmalias: cf switch Named –

Prompts you for confirmation before running the cmdlet.

-Credential pscredential 3 –

A PSCredential object containing a service principal's application ID as the username and client secret as the password. This is not for signing in as a user with a username and password.

-Reset switch Named –

A switch parameter. If provided, the function resets the Fabric authentication token.

Default: False
-ServicePrincipalIdalias: AppId guid 1 –

The Client ID (AppId) of the service principal used for authentication.

-ServicePrincipalSecretalias: AppSecret securestring 2 –

The secure string representing the service principal secret.

-TenantId guid 0 –

The TenantId of the Azure Active Directory tenant you want to connect to and in which your Fabric Capacity is.

-UseDeviceAuthentication switch Named –

A switch parameter. Forces device code authentication instead of the interactive broker/browser flow. Use this when the interactive account picker cannot be displayed by the host terminal (for example Warp on Windows, which does not expose a window handle the WAM broker can parent its UI to). When this switch is not specified, Connect-FabricAccount still falls back to device code authentication automatically if interactive sign-in fails.

Default: False
-WhatIfalias: wi switch Named –

Runs the command in a mode that only reports what would happen without performing the actions.

This cmdlet also supports the common parameters, such as -Verbose and -ErrorAction. See about_CommonParameters.

Outputs

None. This function does not return any output.

{{ Fill in the Description }}

Notes

Revision History:

  • 2024-12-22 - FGE: Added Verbose Output
  • 2025-05-26 - Jojobit: Added Service Principal support, with secure string handling and parameter descriptions, as supported by the original FabTools module
  • 2025-06-02 - KNO: Added Reset switch to force re-authentication and token refresh
  • 2026-08-23 - PBO: Added UseDeviceAuthentication switch and automatic fallback to device code auth when interactive/broker sign-in fails (e.g.

Warp terminal)

Author: Frank Geisler, Kamil Nowinski