if | is OR , what is the symbol for and

Welcome Forums General PowerShell Q&A if | is OR , what is the symbol for and

This topic contains 2 replies, has 2 voices, and was last updated by

1 year, 11 months ago.

  • Author
  • #64654

    Points: 0
    Rank: Member

    $date = (Get-Date).AddDays(-1).ToString('MM/dd/yyyy')
    [String[]]$Match = $content | select-string -Pattern "(Successful incremental backup|$date )"

    This is a statement I am using in my script. So it gives me all the matches which has yesterday`s date in any statmeent. Now , I want a result which has a statement containing yesterday`s date along with "successful incremental backup"

    This is what I want to search :

    02/19/2017 00:49:21 Successful incremental backup of '\\bentpsystpc02\d$'

    So , if | stands for OR , how can I represent AND ???

  • #64758

    Points: 1,811
    Helping HandTeam Member
    Rank: Community Hero

    The -Pattern parameter is accepting a regular expression; the pipe isn't an "OR" operator, it's an alternative set operator, which is a bit different. There's no AND operator per se in regular expression syntax.

    • #65541

      Points: 0
      Rank: Member

      Thanks Don !!!...you have been a great help 🙂

The topic ‘if | is OR , what is the symbol for and’ is closed to new replies.

denizli escort samsun escort muğla escort ataşehir escort kuşadası escort