Powershell Script work in ISE but not Powershell cmd line on same PC RRS feed

  • Question

  • Hey All

    i am having trouble with this script that i wrote, it works correctly in Powershell ISE, but for some reason i can get it to work in powershell cmd line or scheduled task, it returns no errors, and the script looks like it has run successfully but it has not

    i am still new to powershell scripting but i have not had this happen before, any help would be appreciated 

    here is my script that i wrote

    # AppAssure Protected Server Monitor Script,
    # This script will list all Protected servers in appassure and send a pushover notification to the System
    # Administrator if any of the servers come back unreachable
    Import-Module AppAssurePowerShellModule
    Import-Module "C:\Scripts\PS-Pushover.psm1" # Imports Pushover Module
    foreach ($Agent in $Agents)
            $Servers = Get-ProtectedServers
            foreach($Server in $Servers)
                $SrvStatus = $Server.Status
                $SrvName = $Server.DisplayName
                $SSPaused = $Server.IsPaused
                if($SrvStatus -eq 'Unreachable' -and $SSPaused -eq $False)
                    Send-PushoverMessage -Title "Warning Action Required" -user $POUserID -token $POAppAssureGJI -message "Server $SrvName is not being Backed Up, Due to AppAssure Agent Being $SrvStatus" #Sends Pushover message

    • Edited by Kyle Hartigan Friday, May 9, 2014 6:09 AM
    • Moved by Bill_Stewart Tuesday, July 15, 2014 5:32 PM Unanswerable drive-by question
    Friday, May 9, 2014 6:09 AM

All replies

  • As I am not seeing it in the script where are you getting the $Agents?

    foreach ($Agent in $Agents)

    Friday, May 9, 2014 8:47 AM