4 Comments

  1. Harold

    I am having a problem with Appassure restarting/running when servers get rebooted. The following script doesn’t work when running from task scheduler but runs find from command line.
    Any ideas? Think it is a timing issue.

    $servers = Get-ProtectedServers | where status -ne protected | select -expand displayname
    if ($servers.count -ne 0) {
    foreach ($server in $servers){
    Invoke-Command -ComputerName $server -ScriptBlock {Restart-Service AppAssureAgent -PassThru}
    $SmtpClient = new-object system.net.mail.smtpClient
    $MailMessage = New-Object system.net.mail.mailmessage
    $SmtpClient.Host = “smtp.local.com”
    $mailmessage.from = (“mgmt2_task@local.com “)
    $mailmessage.To.add(“admin@local.com”)
    $mailmessage.Subject = “AppAssure Agent restarted on $server”
    $mailmessage.Body = “Powershell script ran from task scheduler on mgmt2”
    $smtpclient.Send($mailmessage)
    }
    }

    Reply
  2. Harold

    This script works from command line but not from powershell. Any clues?
    powershell -file “C:Program FilesAppRecoverygetAAstatus.ps1”

    $servers = Get-ProtectedServers | where status -ne protected | select -expand displayname
    if ($servers.count -ne 0) {
    foreach ($server in $servers){
    Invoke-Command -ComputerName $server -ScriptBlock {Restart-Service AppAssureAgent -PassThru}
    $SmtpClient = new-object system.net.mail.smtpClient
    $MailMessage = New-Object system.net.mail.mailmessage
    $SmtpClient.Host = “smtp.local.com”
    $mailmessage.from = (“mgmt2_task@local.com “)
    $mailmessage.To.add(“admin@local.com”)
    $mailmessage.Subject = “AppAssure Agent restarted on $server”
    $mailmessage.Body = “Powershell script ran from task scheduler on mgmt2”
    $smtpclient.Send($mailmessage)
    }
    }

    Reply

    • Based on my experience with running PowerShell scripts as a scheduled task, I’m going to make the assumption that you’re running it as a different user when it’s running as a scheduled task. Try it with the same user account if this is the case and see if that works. If it does, make sure the user that’s executing the scheduled task has logged into the machine where the scheduled task is setup. I’ve found if the user doesn’t have a profile on the machine, it can cause the problem you’re experiencing. If that doesn’t fix the issue, let me know and I have a few other things you can try.

      Reply
  3. Wolfgang

    It is likely because AppAssure has released a number of new versions since this post, but in order to get the Agent Version listing to work correctly, I had to modify the command line to this:

    Get-protectedServers | where {$_.version -ne “5.3.2.61676”} | select displayname, version | sort displayname

    Mike, thank you for this article, it has been a great starting point for solving some of my information gathering problems in AppAssure.

    Reply

Leave a Reply