Quantcast
Channel: Windows PowerShell Forum
Viewing all articles
Browse latest Browse all 2562

Why doesnt my 'IF' work?

$
0
0

Hello,

When this code hits the 'If' comparison and there is no value in $T1 (determined by test-item), regardless of how I compare $T1 (1. $T1 -eq " " 2. $T1 -eq "" 3. $T1 -eq $null), it always skips to the 'Else' section.  Why?  Also, what do I query to know when my 'IF' test returns a True or False?  Thanks in advance.

$OurMasterDCList = (get-content OurMasterDCList.txt)
$2DaysDCs        = get-addomaincontroller -filter * |  sort name | select -Expandproperty name 
$T1 = $OurMasterDCList | ? {$2DaysDCs -notcontains $_}  # Removed
if ( $T1 -eq " " )
  {
     $T1 = "nothing"
  }
 else
  {


Thanks for your help! SdeDot


Viewing all articles
Browse latest Browse all 2562

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>