The ultimate Microsoft Fabric, Power BI, Azure AI, and SQL learning event: Join us in Stockholm, September 24-27, 2024.
Save €200 with code MSCUST on top of early bird pricing!
Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started
Hello,
We are doing some clean up of sharing links in our environment and are investigating the possibility of seeing if we can programatically complete the process instead of doing it manually. I can grab a list of the items via the API with the "Admin - WidelySharedArtifacts LinksSharedToWholeOrganization" call however there doesn't seem to be any option to programatically add/remove/update these artifacts. I've also tried looking at the PowerShell cmdlets for Power BI however those basically seem to just be wrappers for the regular REST API. Does anybody know if there are any other ways to programatically add/remove/update organization wide sharing links or if the feature is at least being worked on by Microsoft?
I've tried using reviewing Developer Options in my browser and can see requests going to the below endpoint however I can't find any documentation. When I try making HTTP GET/DELETE requests etc I get 401 Unauthorized.
https://wabi-us-east2-d-primary-redirect.analysis.windows.net/metadata/links
@_willie_ @patjones80 Just posting an additional update here for you both, I could not find any workarounds to do this programatically so I just did it manually.
Hi @Leafde
Sorry to hear you had to delete each one manually.
In case this helps anyone we ended putting together a few commands and ran the following
# Check for Power BI Module and install if not found
Write-Host "Checking for Power BI Module"
try
{
Import-Module MicrosoftPowerBIMgmt.Profile
}
catch
{
Install-Module -Name MicrosoftPowerBIMgmt.Profile -Force -AllowClobber
Import-Module MicrosoftPowerBIMgmt.Profile
}
if (!(Get-Module -ListAvailable -Name MicrosoftPowerBIMgmt.Profile))
{
throw "Module MicrosoftPowerBIMgmt.Profile not found"
}
# Enter your Power BI Service URL
# Can be found using F12 > Network > Headers > Request URL
$pbiServiceURL = "https://wabi-us-east2-redirect.analysis.windows.net"
# Connect to PowerBI Service
Write-Host "Connecting to Power BI Service"
$loginInfo = Connect-PowerBIServiceAccount
Write-Host "Logged in as $($loginInfo.UserName)"
# Set token for Power BI API
$token = (Get-PowerBIAccessToken).Authorization
# Get all workspaces
Write-Host "Getting all workspaces"
$aWorkspaces = @()
$tResults = Invoke-PowerBIRestMethod -Url 'admin/groups?$top=5000&$skip=0' -Method GET
$aWorkspaces = ($tResults | ConvertFrom-Json).value
$tResults = $null
# Traverse each workspace
foreach ($workspace in $aWorkspaces)
{
# Grant Admin Access to Workspace
Add-PowerBIWorkspaceUser -Id $workspace.Id -Scope Organization -UserPrincipalName $loginInfo.UserName -AccessRight Admin
Write-Host "Sleeping for 10 seconds..."
Start-Sleep -s 10
$workspaceName = $workspace.Name
Write-Host "Currently on $($workspaceName)"
# get list of workspaces
$lWorkspaceURL = "$($pbiServiceURL)/powerbi/metadata/refreshusermetadata"
$rWorkspace = Invoke-WebRequest -Uri $lWorkspaceURL -Method PUT -Headers @{
"Authorization" = "$token"
}
# get reports for the workspace
# artfactId eq 2 is for reports
$artifactIds = $null
$artifactIds = (($rWorkspace.Content | ConvertFrom-Json).artifactOwnerInfo | Where-Object { $_.groupDisplayName -eq $workspaceName -and $_.artifactType -eq '2' }).artifactId
# traverse each report
foreach ($artifactId in $artifactIds)
{
# get report links
$reportLinkURL = "$($pbiServiceURL)/metadata/links/report/$artifactId"
$rLinks = Invoke-WebRequest -Uri $reportLinkURL -Method GET -Headers @{
"Authorization" = "$token"
} -ErrorAction Stop
# convert json to object
$links = $null
$links = $rLinks.Content | ConvertFrom-Json
# traverse each link
foreach ($link in $links)
{
# if link is for entire org
if ($link.entireOrg -eq $true -and $link.artifactType -eq '2')
{
$linkId = $link.id
$linkURL = "$($pbiServiceURL)/metadata/links/$linkId"
$tResult = Invoke-WebRequest -Uri $linkURL -Method DELETE -Headers @{
"Authorization" = "$token"
}
Write-Host "`tRemoved Link for $($linkId) for $($workspaceName)"
}
}
}
# Remove Admin Access to Workspace
Remove-PowerBIWorkspaceUser -Id $workspace.Id -Scope Organization -UserPrincipalName $loginInfo.UserName
Write-Host ""
}
the script is AS IS and would suggest testing to ensure it works with the intended environment.
Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.
Check out the August 2024 Power BI update to learn about new features.
User | Count |
---|---|
14 | |
2 | |
1 | |
1 | |
1 |