Export-FabricItem, mandatory parameters

This commit is contained in:
RuiRomano 2024-06-21 12:52:31 +01:00
Родитель 0529d322b2
Коммит 00091e6af1
1 изменённых файлов: 83 добавлений и 44 удалений

Просмотреть файл

@ -306,6 +306,7 @@ Function New-FabricWorkspace {
[CmdletBinding()]
param
(
[Parameter(Mandatory)]
[string]$name
,
[switch]$skipErrorIfExists
@ -355,6 +356,7 @@ Function Remove-FabricWorkspace {
[CmdletBinding()]
param
(
[Parameter(Mandatory)]
[string]$workspaceId
)
@ -376,6 +378,7 @@ Function Get-FabricWorkspace {
[CmdletBinding()]
param
(
[Parameter(Mandatory)]
[string]$workspaceName
)
@ -407,8 +410,10 @@ Function Set-FabricWorkspacePermissions {
[CmdletBinding()]
param
(
[Parameter(Mandatory)]
[string]$workspaceId
,
[Parameter(Mandatory)]
$permissions
)
@ -456,35 +461,61 @@ Function Export-FabricItems {
[CmdletBinding()]
param
(
[string]$path = '.\pbipOutput'
[Parameter(Mandatory)]
[string]$path
,
[string]$workspaceId = ''
[Parameter(Mandatory)]
[string]$workspaceId
,
# Focus only on report and semantic model, there are items that are not exportable.
[scriptblock]$filter = {$_.type -in @("report", "SemanticModel")}
,
[string]$format
)
$items = Invoke-FabricAPIRequest -Uri "workspaces/$workspaceId/items" -Method Get
if ($filter) {
#$items = $items | ? { $_.type -in $itemTypes }
$items = $items | Where-Object $filter
}
Write-Host "Existing items: $($items.Count)"
foreach ($item in $items) {
$itemId = $item.id
$itemName = $item.displayName
$itemType = $item.type
$itemNamePath = $itemName.Split([IO.Path]::GetInvalidFileNameChars()) -join '_'
$itemOutputPath = "$path\$workspaceId\$($itemNamePath).$($itemType)"
#Resolve invalid filepath chars
Export-FabricItem -workspaceId $workspaceId -itemId $itemId -path $itemOutputPath
}
}
if ($itemType -in @("report", "semanticmodel")) {
Write-Host "Getting definition of: $itemId / $itemName / $itemType"
Function Export-FabricItem {
<#
.SYNOPSIS
Exports item from a Fabric workspace to a specified local file system destination.
#>
[CmdletBinding()]
param
(
[Parameter(Mandatory)]
[string]$workspaceId
,
[Parameter(Mandatory)]
[string]$itemId
,
[Parameter(Mandatory)]
[string]$path = '.\pbipOutput'
,
[string]$format
)
$itemOutputPath = $path
try {
Write-Host "Getting definition of: $itemId"
#POST https://api.fabric.microsoft.com/v1/workspaces/{workspaceId}/items/{itemId}/getDefinition
@ -522,9 +553,10 @@ Function Export-FabricItems {
}
}
}
else {
Write-Host "Type '$itemType' not available for export."
}
catch{
$ex = $_.Exception
Write-Warning "Error exporting item '$itemId' - '$($ex.ToString())'"
}
}
@ -543,8 +575,10 @@ Function Import-FabricItems {
[CmdletBinding()]
param
(
[Parameter(Mandatory)]
[string]$path = '.\pbipOutput'
,
[Parameter(Mandatory)]
[string]$workspaceId
,
[string[]]$filter = $null
@ -862,8 +896,10 @@ Function Import-FabricItem {
[CmdletBinding()]
param
(
[Parameter(Mandatory)]
[string]$path = '.\pbipOutput'
,
[Parameter(Mandatory)]
[string]$workspaceId
,
[hashtable]$itemProperties
@ -1082,6 +1118,7 @@ Function Remove-FabricItems {
[CmdletBinding()]
param
(
[Parameter(Mandatory)]
[string]$workspaceId = $null
,
[string]$filter = $null
@ -1114,8 +1151,10 @@ Function Set-SemanticModelParameters {
[CmdletBinding()]
param
(
[Parameter(Mandatory)]
[string]$path = $null
,
[Parameter(Mandatory)]
[hashtable]$parameters = $null
,
[switch]$failIfNotFound