ssas-tabular - 通过 PowerShell 编写 SSAS 表格角色脚本的问题
问题描述
我正在尝试创建一个将输出 SSAS 表格角色的 Powershell 脚本,但我遇到了一些困难。我在网上搜索了帮助,发现了一些似乎相当普遍但由于某种原因对我不起作用的代码。代码如下
[System.Reflection.Assembly]::LoadWithPartialName(“Microsoft.AnalysisServices.Tabular”) > $NULL
$Server = New-Object Microsoft.AnalysisServices.Server
If ($? -eq $False)
{
Throw “Cannot load assembly”
EXIT
}
# SSAS server name variable
$SSASServerName = "."
# Try to connect to the SSAS server
$SSASServer = New-Object Microsoft.AnalysisServices.Server
$SSASServer.Connect($SSASServerName)
# Object to store the result
$Result = @()
# Get the SSAS databases and loop thru each of them
foreach ($DB in $SSASServer.Databases)
{
# Get the SSAS database
$SSASDatabase = $SSASServer.Databases.Item($DB.ID)
# Get the roles available within the SSAS database and loop thru each of them
foreach ($Role in $SSASDatabase.Roles)
{
# Get the members within the role and loop thru each one of them
foreach ($UserName in $Role.Members)
{
# Create a new object that would store the database name, role name and member user name
$ItemResult = New-Object System.Object
$ItemResult | Add-Member -type NoteProperty -name DatabaseName -value $DB.Name
$ItemResult | Add-Member -type NoteProperty -name RoleName -value $Role.Name
$ItemResult | Add-Member -type NoteProperty -name UserName -value $UserName.Name
# Put the item result and append it to the result object
$Result +=$ItemResult
}
}
}
当我运行它时,它不会返回任何错误,但不会给我任何角色,并且服务器上的 SSAS 数据库中有很多角色。它似乎为 Roles 属性返回一个空集。
有人可以帮我指出我出错的方向吗?
在此先感谢迈克
解决方案
推荐阅读
- spring - 我应该在 Spring 应用程序、控制器或服务中的哪里进行 API 调用?
- flutter - 如何使用不同的 ScrollController 到 NestedScrollView,以及 tabls 中的两个 CustomScrollView?
- c - C中的拆分链表
- c++ - 如何更新原始二叉搜索树并返回新树?
- applescript - Applescript “Google Chrome 出现错误:无法将窗口 id 1 的 |tabs| 设置为类型说明符。”
- java - 上传文件excel并在java中使用JAX-RS 2.0读取
- kml - 为什么我的 KML gx 扩展名称空间不起作用
- node.js - 为什么我的 lambda 将空白图像上传到 s3
- python - python中“链表”的一个很好的例子是什么?
- python - 无法使用 python 程序写入数据库