Announcement

Collapse
No announcement yet.

What does !$_. mean?

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • What does !$_. mean?

    In this script, what is the function of !$_.

    Code:
    get-aduser -searchbase "ou=users,dc=contoso,dc=com" -filter * -properties PasswordExpired, PasswordNeverExpires
    
        if (!$_.PasswordExpired -and !$_.PasswordNeverExpires) { do whatever bla bla bla}
    Does if (!$_.PasswordExpired -and !$_.PasswordNeverExpires) mean, if those two vaules are FALSE?

  • #2
    Re: What does !$_. mean?

    $_. refers to a property of the current object, and ! is a negation (NOT) so
    "If the password is not expired and if the password does expire" (translation of "not password doesn't expire")
    Tom Jones
    MCT, MCSE (2000:Security & 2003), MCSA:Security & Messaging, MCDBA, MCDST, MCITP(EA, EMA, SA, EDA, ES, CS), MCTS, MCP, Sec+
    PhD, MSc, FIAP, MIITT
    IT Trainer / Consultant
    Ossian Ltd
    Scotland

    ** Remember to give credit where credit is due and leave reputation points where appropriate **

    Comment


    • #3
      Re: What does !$_. mean?

      Thanks.

      So

      Code:
      if (!$_.PasswordExpired -and !$_.PasswordNeverExpires)
      is basically the same as

      Code:
      if ($_.PasswordExpired -eq "false" -and $_.PasswordNeverExpires -eq "false")

      Comment


      • #4
        Re: What does !$_. mean?

        Yup (without testing it...)
        Tom Jones
        MCT, MCSE (2000:Security & 2003), MCSA:Security & Messaging, MCDBA, MCDST, MCITP(EA, EMA, SA, EDA, ES, CS), MCTS, MCP, Sec+
        PhD, MSc, FIAP, MIITT
        IT Trainer / Consultant
        Ossian Ltd
        Scotland

        ** Remember to give credit where credit is due and leave reputation points where appropriate **

        Comment

        Working...
        X