Public/Get-FabricWorkspace.ps1

Function Get-FabricWorkspace {
        <#
    .SYNOPSIS
        Retrieves Fabric workspace information by name.
     
    .DESCRIPTION
        The Get-FabricWorkspace cmdlet retrieves information about a specific Microsoft Fabric workspace
        by its display name. It invokes the Fabric REST API to fetch workspace details.
         
        This cmdlet requires proper authentication to the Fabric API before use.
     
    .PARAMETER workspaceName
        The display name of the workspace to retrieve. The search is case-insensitive.
 
    .EXAMPLE
        Get-FabricWorkspace -workspaceName "Marketing Analytics"
         
        Retrieves the workspace with display name "Marketing Analytics".
     
    .OUTPUTS
        PSCustomObject representing the Fabric workspace with properties such as id, displayName, etc.
     
    .NOTES
        Requires an authenticated session to the Fabric API.
        The function will throw an error if no workspace is found with the specified name.
    #>

    [CmdletBinding()]
    param
    (
        [Parameter(Mandatory)]
        [string]$workspaceName
    )
      
    $result = Invoke-FabricApiRequest -Uri "workspaces" -Method Get

    if ($workspaceName) {
        $workspace = $result | ? { $_.displayName -ieq $workspaceName }

        if (!$workspace) {
            throw "Cannot find workspace '$workspaceName'"
        }

        Write-Output $workspace
    }
    else {
        Write-Output $result
    }
    
}