magritton
10/28/2015 - 4:08 PM

SharePoint Powershell testing of the Analysis services in SharePoint mode. This is used in troublshooting the Analysis services in SharePoin

SharePoint Powershell testing of the Analysis services in SharePoint mode. This is used in troublshooting the Analysis services in SharePoint.

$ssasServers = Get-SPExcelServiceApplication | Get-SPExcelBIServer $_
if(-Not $ssasServers) { Write-Host "The server pool is empty." } else { $ssasServers }

$adomd = [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.AnalysisServices.AdomdClient")
Write-Host (dir $adomd.Location).VersionInfo.FileVersion –ForegroundColor Yellow


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

$server = "scushp01\POWERPIVOT"
$adomd = new-object Microsoft.AnalysisServices.AdomdClient.AdomdConnection
$adomd.ConnectionString = "Data Source=$server;"
$adomd.Open()
if($adomd.State –eq "Open") {Write-Host "Connected" –ForegroundColor Yellow} else {Write-Host "Connection failed." –ForegroundColor Red}
$adomd.Close()

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

$server = "http://scushp01/sites/Testing/Shared%20Documents/Book1.xlsx"
$adomd = new-object Microsoft.AnalysisServices.AdomdClient.AdomdConnection
$adomd.ConnectionString = "Datasource=$server;"
$adomd.Open()
if($adomd.State –eq "Open") {Write-Host "Workbook loaded" –ForegroundColor Yellow} else {Write-Host "Workbook loading failed." –ForegroundColor Red}
$adomd.Close()

$spclient = [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.AnalysisServices.SPClient")
if($spclient) {Write-Host "SPClient is installed." –ForegroundColor Yellow} else {Write-Host "SPClient is not installed." –ForegroundColor Red}

##Determine the admins for the Analysis server
[Reflection.Assembly]::LoadWithPartialName("Microsoft.AnalysisServices")

$server = "scushp01\POWERPIVOT"
$amo = New-Object Microsoft.AnalysisServices.Server

$amo.Connect($server)
$admins = $amo.Roles.GetByName("Administrators")
foreach($admin in $admins.Members){Write-Host $admin.Name –ForegroundColor Yellow}
$amo.Disconnect()

[Reflection.Assembly]::LoadWithPartialName("Microsoft.AnalysisServices")

$server = "scushp01\POWERPIVOT"
$amo = New-Object Microsoft.AnalysisServices.Server

$amo.Connect($server)
Write-Host "The SSAS server version is: " $amo.Version –ForegroundColor Yellow
$amo.Disconnect()

[Reflection.Assembly]::LoadWithPartialName("Microsoft.AnalysisServices")

$server = "scushp01\POWERPIVOT"
$amo = New-Object Microsoft.AnalysisServices.Server

$amo.Connect($server)
$mode = $amo.ServerMode
Write-Host "The SSAS server is operating in $mode mode." –ForegroundColor Yellow
$amo.Disconnect()

##Tests opening the workbook
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.AnalysisServices.AdomdClient")

$server = "http://scushp01/sites/Testing/Shared%20Documents/Book1.xlsx"
$adomd = new-object Microsoft.AnalysisServices.AdomdClient.AdomdConnection
$adomd.ConnectionString = "Datasource=$server;"
$adomd.Open()
if($adomd.State –eq "Open") {Write-Host "Workbook loaded" –ForegroundColor Yellow} else {Write-Host "Workbook loading failed." –ForegroundColor Red}
$adomd.Close()