Yes, you have to replace $tag with the variable where you stored the tags you want to assign.
It looks like the $vm variable is empty, I would need to see your actual code again to analyse
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference