Introduction
Having created a workspace, a lakehouse, a warehouse, a Fabric SQL database previously, it’s time to move onto something a little more interesting. I was getting bored writing the same post over and over again, so I thought I would show you how to list the items in a Fabric Workspace using PowerShell. This command was super useful for me today to answer the question “What do they have in this workspace?” and I hope it will be useful for you too.
What is FabricTools?
We are going to use FabricTools, a PowerShell module that simplifies the management of Microsoft Fabric resources. You can find it on GitHub at FabricTools. It has been developed and is maintained by members of the community.
How do you list the items in a Fabric Workspace with PowerShell?
To list the items in a Fabric Workspace with PowerShell, you first need to connect to your Fabric account using the Connect-FabricAccount
cmdlet. This cmdlet will prompt you to sign in with your Microsoft account. I like to use a secret to store my tenant ID, so I can use it in my scripts without hardcoding it. You can use the Get-Secret
cmdlet from the Microsoft.PowerShell.SecretManagement module to retrieve the secret.
|
|
You can list all of the items in a Fabric Workspace by getting the Fabric Workspace and then piping it to the Get-FabricItem
cmdlet.
|
|
This will list all the items in the specified Fabric Workspace. The output will include the item type, name, and other details.
You can also filter the items by type using the -Type
parameter. For example, to list only the Fabric SQL databases in the workspace, you can use:
|
|
You can also filter by other types such as lakehouse, warehouse, etc.
It’s Just PowerShell
The beauty of using PowerShell to manage Fabric resources is that you can easily script and automate these tasks. You can combine these commands with other PowerShell cmdlets to create more complex scripts that suit your needs. You can use your existing PowerShell skills and knowledge.
PowerShell makes it easy.
For example in the above items list, the output is the default output and comes out as a list of objects. You can use the Format-Table
cmdlet to format the output in a more readable way. For example, you can use:
|
|
You can update the output by using calculated properties to show the item type in a more readable way. For example, you can use:
|
|
It’s PowerShell, so you can output to a csv
|
|
It’s PowerShell, so you can output to a json file
|
|
It’s PowerShell, so you can output to an Excel file
|
|
There are obviously many more things you can do with PowerShell and indeed with FabricTools, but I hope this gives you a good starting point to explore the possibilities.