powershell filter

Sara 441 Reputation points
2020-08-23T16:29:29.5+00:00

,

    #This will only send the alerts.

                         If (($SendAlert) -and (-not (((get-date).TimeOfDay.totalhours -ge 1) -and ((get-date).timeofday.totalhours -lt 4))))

                         {

                                       $Message = @"

$server is not converting

Information: $ErrorResult


**Ok ,I just need a additional line to be added on the script to remove alert and put in a filter like

-and ($errorresult notmatch "E:\Program Files (x86)\data")** , The question is ,can this be added along these lines

If (($SendAlert) -and (-not (((get-date).TimeOfDay.totalhours -ge 1) -and ((get-date).timeofday.totalhours -lt 4)))) ? or where and how it can be added effectively?

Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,546 questions
{count} votes

Accepted answer
  1. SChalakov 10,391 Reputation points MVP
    2020-08-24T09:39:58.133+00:00

    Hi @Saravanaraj-6475 ,

    I would put the last condition in brackets, like that:

     If ($SendAlert -and (((get-date).TimeOfDay.Hours -lt 1) -and ((get-date).timeofday.Hours -gt 3))-and ($ErrorResult.ErrorDetails -notlike "E:\Program Files (x86)\data"))
    

    hope this helps.


    (If the reply was helpful please don't forget to upvote or accept as answer, thank you)
    Best Regards!
    Stoyan

    1 person found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. Sara 441 Reputation points
    2020-08-24T09:33:39.2+00:00

    Thanks Rich,

    Does anybody else have any other suggestions? , If ($SendAlert -and (((get-date).TimeOfDay.Hours -lt 1) -and ((get-date).timeofday.Hours -gt 3))-and $ErrorResult.ErrorDetails -notlike "E:\Program Files (x86)\data")

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.