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

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -