What is the best way of checking if a string array is NULL?


hello,

i run following find records today's date , determine string array $todaysncsrecords not null.  if array $todaysncsrecords contains number of values, understanding comparison not return boolean value, best way check if string array not null , has values?  think boolean result want based on my comparison.

$servername = $env:computername
$todaysdate = get-date -displayhint date -format mm/dd
$todaysncsrecords = get-content \\$servername\c$\testdir\transactions.log | ? {$_ -match $todaysdate}
if ($todaysncsrecords -eq $null)


thanks help! sdedot

 

$servername = $env:computername  $todaysdate = get-date -displayhint date -format mm/dd  $todaysncsrecords = @(get-content \\$servername\c$\testdir\transactions.log | ? {$_ -match $todaysdate})  if ($todaysncsrecords.count -eq 0) {} 

if result get-content... command returns 1 line, not array, scalar string. bear in mind.

 

i cast results of get-content command array, in case, , check value of .count.

 


[string](0..9|%{[char][int](32+("39826578840055658268").substring(($_*2),2))})-replace "\s{1}\b"



Windows Server  >  Windows PowerShell



Comments

Popular posts from this blog

Group Policy Event ID 1058 Error Code 1326 (The user name or password is incorrect)

Suspicious event log Event ID: 4905

DCOM received error "2147746132" from...