What is the best way to determine if a variable is empty or populated with data?


hi,

i execute following intent determine if get-aduser found samaccountname in directory.

is better check data using method below or there safer, more accurate way test existence of data , cmdlet successful?

$aduser = ""  $aduser = get-aduser -filter 'samaccountname -eq "jflary"'                if($aduser) {                  write-host "string not empty"              } else {                  write-host "string empty or null"              }   


thanks help! sdedot

hi,

that's method use. have had problems or question out of curiosity?




Windows Server  >  Windows PowerShell



Comments

Popular posts from this blog

server manager error: ADAM.events.xml could not be enumerated.

Cannot access Anywhere Access using domain name?

WMI Failure: Unable to update Local Resource Group