Created
January 22, 2021 06:16
-
-
Save dgosbell/75a4c2b6c1eae6ba1a8f4fdddd995119 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### Author: Darren Gosbell (https://darren.gosbell.com) | |
### Date : 22 Jan 2021 | |
### Usage : To use this script just update the following 4 variables for you environment | |
$server = "localhost\tab17" | |
$database = "adventure works" | |
$query = “evaluate 'Date'” | |
$filename = “c:\temp\tofile.csv” | |
# this line assumes you have installed the ADOMD Analysis Services client library on your machine | |
# you will have this if you have installed SSMS otherwise it can be downloaded from | |
# https://docs.microsoft.com/en-us/analysis-services/client-libraries?view=asallproducts-allversions | |
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.AnalysisServices.AdomdClient") > $null | |
$connection = New-Object -TypeName Microsoft.AnalysisServices.AdomdClient.AdomdConnection | |
$connection.ConnectionString = “Data Source=$server;Initial Catalog=$database;” | |
$command = $connection.CreateCommand() | |
$command.CommandText = $query | |
$adapter = New-Object -TypeName Microsoft.AnalysisServices.AdomdClient.AdomdDataAdapter $command | |
$dataset = New-Object -TypeName System.Data.DataSet | |
$rowsOutput = $adapter.Fill($dataset) | |
$dataset.Tables[0] | export-csv $filename -notypeinformation | |
$connection.Close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
thank you so much this helped !