Using PowerShell for SSAS
to check service status and database availability
Type
“get-service” Command to list out the service present in Services.msc
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
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}
No comments:
Post a Comment