Noit is not.I manually Ran the comand inside the IF and it does return a value to the variable.
Similarly the value of the variable outside the IF is true..So it never executes the if.
I tried it manually bu assigning the $logpath variable both the values .But both times it failed in get-datastoreitem.
I had browsed the vcenter going though datastore and saw the datastore.