Friday, August 9, 2013

Using PowerShell for SSAS to check service status and database availability...


Using PowerShell for SSAS to check service status and database availability

 Enter the “Powershell” Command in the Run Command Prompt


Type “get-service” Command to list out the service present in Services.msc



 In Case of Analysis Services, enter the Command provided below
 
get-service | select status, name | Where-Object {$_.Name -like  "*MSSQLServerOLAP*"}
get-service | select status, name | Where-Object {$_.Name -like  "*MSOLAP$TABULAR*"}



 




 

We are going to provide a message if the SSAS Service is already stopped

$servicestatus=get-service | select status, name | Where-Object {$_.Name -like “*MSSQLServerOLAP*"}

$Message="The SSAS Service is down"

if($servicestatus.status -eq "Stopped"){

echo $Message

 }



 


$driveinformation=gwmi win32_volume -Filter 'drivetype = 3' | select driveletter, label, @{LABEL='GBfreespace'; EXPRESSION={$_.freespace/1GB} } 

Then type $driveinformation which is declared as a variable

$driveinformation


 
Open & browser the Cube. Create the following Query as shown



Go to Query Mode as shown and Save the query in MDX file in a location



 

 
 
 
 
 
 
 
 
 
Write the below Code inside a JOB [Change Database Name and Input file Location]

$result=Invoke-ASCmd -Database "AdventureCUBE" -InputFile:"D:\Scripts\Adventure.mdx" $Message="Adventureworks had a connection error" If ((!$result) -or ($resultado -like “*either does not exist or has not been processed*")){$message}

 


 To Create a JOB, follow the step below



 



 

No comments: