zoukankan      html  css  js  c++  java
  • powershell4ssas笔记

    连接SSAS方法1,通过ADOMD.NET

    #import dll

    add-type -path "Microsoft.AnalysisServices.AdomdClient.dll"

     

    #create connection

    $c=new-object Microsoft.AnalysisServices.AdomdClient.AdomdConnection

    $c.ConnectionString="Integrated Security=SSPI;Persist Security Info=True;Initial Catalog=Adventure Works DW 2008;Data Source=localhost"

    $c.Open()

    foreach ($cube in $c.Cubes)

    {

    if ($cube.Type -eq [CubeType]::Cube)

    write-host $cubes

    }

    关键点:

    Add-Type:相当于在c#中添加一个dll进来。

    New-Object:声明一个.net对象

    -eq相当于c#==

     

     

    连接SSAS方法2,通过AMO连接,并且备份cube

    $s=[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.AnalysisServices")

    $server=New-Object Microsoft.AnalysisServices.Server

    $server.connect("Integrated Security=SSPI;Persist Security Info=True;Initial Catalog=Adventure Works DW 2008;Data Source=.")

    $db=$server.databases.item("Adventure Works DW 2008")

    $db.backup("d:\mmm.abf")

    第一行,声明一个.net对象的另一种方法。

    备份直接在Database对象上操作就可以。

     

     

    Process cube

    [System.reflection.Assembly]::LoadWithPartialName("Microsoft.AnalysisServices")

    [Microsoft.AnalysisServices.Server]$svr = new-Object Microsoft.AnalysisServices.Server

    $svr.Connect("Integrated Security=SSPI;Persist Security Info=True;Initial Catalog=Adventure Works DW 2008;Data Source=localhost")

    #define error configuration

    $svr.CaptureXml=$true

    [Microsoft.AnalysisServices.Database] $_db=$svr.Databases.FindByName("Adventure Works DW 2008")

    $_db.Cubes.FindByName("Adventure Works").Process()

    $_db.Process()

    $svr.CaptureXml=$false

    #write out XMLA

    foreach ($v in $svr.CaptureLog)

    {

        write-output $v

    }

    #begin to process

    [Microsoft.AnalysisServices.XmlaResultCollection] $_result = $svr.ExecuteCaptureLog($true,$true)

    write-output "Process Waring and errors:"

    foreach ($r in $_result)

    {

        foreach ($m in $r.Messages)

        {

            write-output "$m.Description"

        }

    }

    关键点:

    每一个ssas object都有一个process方法,而且都需要套在$svr.CaptureXml=$true$svr.CaptureXml=$false中间,process方法后的object会生成相应的xmla对象用来处理cube

    Xmla是放在Server对象中的,CaptureLog是一个行集需要枚举读取出来Capturexmla是什么样的。

    ServerExecuteCaptureLog方法真正处理生成的xmla,结果是一个XmlaResultCollection对象。里面有cube的处理记录,跟手动在项目里处理cube的差不多,不过是同步的,没有找到异步方法。

     

     

  • 相关阅读:
    ConcurrentHashMap使用示例
    vss的ss.ini丢失或损坏导致的vss无法登录错误
    Arcgis中用滚轮做放大缩小为什么和一般软件反向
    MapControl控件
    string截取字符串
    C# CheckedListBox控件用法总结(怎样得到多选的值)
    通信串口中报ObjectDisposedException错误时怎么解决
    C#串口SerialPort常用属性方法
    SerialPort.DataReceived 事件
    C#的串口编程
  • 原文地址:https://www.cnblogs.com/aspnetx/p/1749739.html
Copyright © 2011-2022 走看看