It works

and that’s good, but there’s a typo, change:
if($excludeVM -ne “”
to
if($excludeVM -ne “”)