Share via


Get Analysis Services properties that are no longer in default Powershell

You could find below a sample a script powershell to see which property is no default value of Analysis Services:

 

$serverName = "serverName\SQL2008_InstanceName"

# Load the AMO assembly in Powershell
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.AnalysisServices")

# Create a server object
$serverAS = New-Object Microsoft.AnalysisServices.Server

# Connect to your Analysis Services server
$serverAS.connect($serverName)

# Creation of my dataset to store my result
$myDS = new-object System.Data.DataSet
$myDS.Tables.Add("myDS")
$myDS.Tables["myDS"].Columns.Add("name",[string])| out-null
$myDS.Tables["myDS"].Columns.Add("value",[string])| out-null
$myDS.Tables["myDS"].Columns.Add("defaultvalue",[string])| out-null

# Browsing all properties to see which one has been changed  
foreach($b in $serverAS.ServerProperties | SELECT name,value,defaultvalue )
{
    # Check if the current value is different from the default value
    if ($b.value -ne $b.defaultvalue)
    {       
   
        # Add a new row to my Data Set
        $dr = $myDS.Tables["myDS"].NewRow()
       
        # Fill the cells
        $dr["name"] =  $b.name;
        $dr["value"] = $b.value.ToString();
        $dr["defaultvalue"] = $b.defaultvalue;
       
        $myDS.Tables["myDS"].Rows.Add($dr)

    }

}

# Query the result
$myDS.Tables["myDS"] | SELECT  name,value,defaultvalue;

 

Michel Degremont | Premier Field Engineer - SQL Server Core Engineer |