How to get list of roles and members in an Azure Anlysis service via Powershell

Priya Jha 871 Reputation points
2021-01-15T13:40:56.68+00:00

We want to get the list of roles and members existing in an Azure Analysis services via Powershell.
Is it possible?
https://learn.microsoft.com/en-us/azure/analysis-services/analysis-services-powershell
Based on these list , I did not get any list to get these details

Azure Analysis Services
Azure Analysis Services
An Azure service that provides an enterprise-grade analytics engine.
444 questions
{count} votes

Accepted answer
  1. Saurabh Sharma 23,791 Reputation points Microsoft Employee
    2021-01-19T19:17:59.197+00:00

    @Priya Jha You need to call the tabular object model directly from Powershell scripts. Please find below script which will give the roles and members of a Model.

    [Reflection.Assembly]::LoadWithPartialName("Microsoft.AnalysisServices")  
      
    $ServerName = "asazure://westus.asazure.windows.net/abc:rw"  
    $DB = "adventureworks"   
      
    $MyServer = New-Object Microsoft.AnalysisServices.Server  
    $MyServer.Connect($ServerName)  
      
    $myDatabase = $myServer.Databases.Item($DB)  
      
    foreach ( $roles in $myDatabase.Model.Roles) {  
        #Write-Output $roles.Name  
        foreach ( $role in $roles) {  
        Write-Output $role.Name  
        Write-Output "----------------------"  
        foreach ( $member in $roles.Members) {  
             "Member Name: "  + $member.Name  
            }  
            Write-Output "`n"  
          }  
    }  
    

    Output:
    58272-image.png

    Model as appears on SSMS:
    58291-image.png

    ----------

    Please do not forget to "Accept the answer" wherever the information provided helps you to help others in the community.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful