1
votes

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

1

1 Answers

0
votes

I have provided a solution over here. You basically 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" 
    
 $Server = New-Object Microsoft.AnalysisServices.Server
 $Server.Connect($ServerName)
    
 $Database = $Server.Databases.Item($DB)
    
 foreach ( $roles in $Database.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: enter image description here