if statement - Powershell Out-file with variable -


i'm trying write script check if string null , if output user name file can go , check file , see null. below code, script not writing out-file ideas?

$user = "user@domain.com" #just gets users info $user_info = gam info user $user  $suspended = $user_info | select-string -pattern "account suspended: true" if ($suspended = $null) {   $user | out-file -filepath c:\scripts\not_suspended.txt -append -encoding utf8   } 

you assigning $null $suspended in if statement. use -eq instead comparison:

if ($suspended -eq $null) {   $user | out-file -filepath c:\scripts\not_suspended.txt -append -encoding utf8 } 

Comments

Popular posts from this blog

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -

java - Why does my date parsing return a weird date? -

Need help in packaging app using TideSDK on Windows -