<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Add/Remove/Update Organization Wide Sharing Links in Developer</title>
    <link>https://community.fabric.microsoft.com/t5/Developer/Add-Remove-Update-Organization-Wide-Sharing-Links/m-p/3543757#M45434</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;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 "&lt;A href="https://learn.microsoft.com/en-us/rest/api/power-bi/admin/widely-shared-artifacts-links-shared-to-whole-organization" target="_self"&gt;Admin - WidelySharedArtifacts LinksSharedToWholeOrganization&lt;/A&gt;" call however there doesn't seem to be any option to programatically add/remove/update these artifacts.&amp;nbsp;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?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;A href="https://wabi-us-east2-d-primary-redirect.analysis.windows.net/metadata/links" target="_blank" rel="noopener"&gt;https://wabi-us-east2-d-primary-redirect.analysis.windows.net/metadata/links&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 21 Nov 2023 05:18:40 GMT</pubDate>
    <dc:creator>Leafde</dc:creator>
    <dc:date>2023-11-21T05:18:40Z</dc:date>
    <item>
      <title>Add/Remove/Update Organization Wide Sharing Links</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Add-Remove-Update-Organization-Wide-Sharing-Links/m-p/3543757#M45434</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;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 "&lt;A href="https://learn.microsoft.com/en-us/rest/api/power-bi/admin/widely-shared-artifacts-links-shared-to-whole-organization" target="_self"&gt;Admin - WidelySharedArtifacts LinksSharedToWholeOrganization&lt;/A&gt;" call however there doesn't seem to be any option to programatically add/remove/update these artifacts.&amp;nbsp;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?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;A href="https://wabi-us-east2-d-primary-redirect.analysis.windows.net/metadata/links" target="_blank" rel="noopener"&gt;https://wabi-us-east2-d-primary-redirect.analysis.windows.net/metadata/links&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Nov 2023 05:18:40 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Add-Remove-Update-Organization-Wide-Sharing-Links/m-p/3543757#M45434</guid>
      <dc:creator>Leafde</dc:creator>
      <dc:date>2023-11-21T05:18:40Z</dc:date>
    </item>
    <item>
      <title>Re: Add/Remove/Update Organization Wide Sharing Links</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Add-Remove-Update-Organization-Wide-Sharing-Links/m-p/3903054#M52252</link>
      <description>Did you ever get anywhere with this? I've got about 350 such links that I'd like to remove and would prefer not to do it manually. Thanks!</description>
      <pubDate>Wed, 08 May 2024 17:53:30 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Add-Remove-Update-Organization-Wide-Sharing-Links/m-p/3903054#M52252</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-05-08T17:53:30Z</dc:date>
    </item>
    <item>
      <title>Re: Add/Remove/Update Organization Wide Sharing Links</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Add-Remove-Update-Organization-Wide-Sharing-Links/m-p/4026350#M53947</link>
      <description>&lt;P&gt;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/649424"&gt;@Leafde&lt;/a&gt;,&amp;nbsp; By any chance, did you find any alternative to remove the Org Links?&lt;/P&gt;</description>
      <pubDate>Fri, 05 Jul 2024 06:14:00 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Add-Remove-Update-Organization-Wide-Sharing-Links/m-p/4026350#M53947</guid>
      <dc:creator>_willie_</dc:creator>
      <dc:date>2024-07-05T06:14:00Z</dc:date>
    </item>
    <item>
      <title>Re: Add/Remove/Update Organization Wide Sharing Links</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Add-Remove-Update-Organization-Wide-Sharing-Links/m-p/4067811#M54408</link>
      <description>&lt;P&gt;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/770965"&gt;@_willie_&lt;/a&gt;&amp;nbsp;@Anonymous&amp;nbsp;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.&lt;/P&gt;</description>
      <pubDate>Tue, 30 Jul 2024 00:07:19 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Add-Remove-Update-Organization-Wide-Sharing-Links/m-p/4067811#M54408</guid>
      <dc:creator>Leafde</dc:creator>
      <dc:date>2024-07-30T00:07:19Z</dc:date>
    </item>
    <item>
      <title>Re: Add/Remove/Update Organization Wide Sharing Links</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Add-Remove-Update-Organization-Wide-Sharing-Links/m-p/4068148#M54414</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/649424"&gt;@Leafde&lt;/a&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sorry to hear you had to delete each one manually.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In case this helps anyone we ended putting together a few commands and ran the following&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;# 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 &amp;gt; Network &amp;gt; Headers &amp;gt; 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&amp;amp;$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 ""

}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;the script is AS IS and would suggest testing to ensure it works with the intended environment.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 30 Jul 2024 03:19:57 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Add-Remove-Update-Organization-Wide-Sharing-Links/m-p/4068148#M54414</guid>
      <dc:creator>_willie_</dc:creator>
      <dc:date>2024-07-30T03:19:57Z</dc:date>
    </item>
  </channel>
</rss>

