lundi 11 mai 2020

Powershell Array length

I have written the below to error trap an empty array and it isn't working. Any ideas on the syntax I need?

$inputstring =   "MyOtherFile.rdl" "MyFile.rdl"
$cleanstring =  $inputstring.replace(""" """,";")
$filearray = $inputstring.split(";")

if (echo @($filearray).length = "0")


{$filearray.length
'No Files Selected'

exit}

else
{$filearray.length}

It is returning 2 for the array length but is still tripping the 1st part of the IF and saying no files selected.

Aucun commentaire:

Enregistrer un commentaire