locked
add email for alerting RRS feed

  • Question

  •   

     How could I add multiple servers to status of SSAS, and if state<> Processed send an email alert?

     Currently just one server lookup with file capture.

     Thanks.

    [CmdletBinding()]
    
    $ssasInstance = 'xxxxxx'
     
    [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.AnalysisServices")
    $server = New-Object Microsoft.AnalysisServices.Server
    $server.connect($ssasInstance)
    $database=$server.databases
    foreach ($db in $server.databases)
    {
    $dbwriteout = $db|select name,state
    $dbwriteout | Sort name | Export-Csv 'C:\cube_status.csv' -Append -NoTypeInformation
    $Cubes=New-object Microsoft.AnalysisServices.Cube
    $Cubes=$db.cubes
    }

    Thursday, June 4, 2020 5:45 PM

All replies

  • Call the code in a loop and use "Send-MailMessage" to send email.

    If you search you will find hundreds of examples of how to do this.


    \_(ツ)_/

    Thursday, June 4, 2020 8:09 PM
  •  Okay I have the first part, but how do I get that in the email piece.?

     Thanks.

    [CmdletBinding()]
    
    $ssasInstance = @('server1','server2')
    
    
     
    [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.AnalysisServices")
    ForEach($srv in $ssasInstance) {
    $server = New-Object Microsoft.AnalysisServices.Server
    $server.connect($srv)
    $database=$server.databases
    foreach ($db in $server.databases)
      {
      
    $dbwriteout = $db|select parentserver,name,state
    $dbwriteout | Sort parentserver | Export-Csv 'C:\cube_status.csv' -Append -NoTypeInformation
    $Cubes=New-object Microsoft.AnalysisServices.Cube
    $Cubes=$db.cubes
      }
    }

    Monday, June 29, 2020 4:48 PM
  • What are you trying to get in the email.

    Here is a place to start learning PowerShell. It will answer all of your current questions and thos you will ask in the next few months.  REad it carefully to understand what PowerShell is and how it works:


    \_(ツ)_/

    Monday, June 29, 2020 4:50 PM
  • Hi,
    Was your issue resolved? 
    If you resolved it using our solution, please "mark it as answer" to help other community members find the helpful reply quickly.
    If you resolve it using your own solution, please share your experience and solution here. It will be very beneficial for other community members who have similar questions.
    If no, please reply and tell us the current situation in order to provide further help.
    Best Regards,
    Yang Yang

    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    Friday, July 3, 2020 3:29 AM