none
Simple Comparison using -ne Not working as I expect RRS feed

  • Question

  • I have this situation where I'm looking up the Pool Registrar on my Lync server,  using Powershell I perform the following.

     

    Get-CSUser | ? {
        $_.RegistrarPool -ne "SERVER-USER-POOL.example.com" -and
        $_.Enabled -eq $True
    } | select SamAccountName, LineURI, RegistrarPool

    Instead of returning back what I wanted which was everything that isn't  "SERVER-USER-POOL.example.com" it returns back everything including "SERVER-USER-POOL.example.com".

    If I change this around a bit to the following,  I get the results I expect.

    Get-CSUser -filter  {
               RegistrarPool -ne "SERVER-USER-POOL.example.com" -and 
               Enabled -eq $True
               } | select SamAccountName, LineURI, RegistrarPool

    Going a bit further I can also run the following which Also gives me what I expect

    Get-CSUser | ? {
        $_.RegistrarPool -notlike "SERVER-USER-POOL.example.com" -and
        $_.Enabled -eq $True
    } | select SamAccountName, LineURI, RegistrarPool

    The only difference here is I changed $_.RegistrarPool -ne  to  $_.RegistrarPool -notlike

    Is there some bug with with the -ne evaluation or am I doing something wrong here?




    Sunday, February 28, 2016 8:17 PM

All replies