I have saved in new text file and ran it nw its working fine.. Thanks LucD for your help, I have been struggling with this for past two days..You are awesome really..
LucD I need one more help from you..Hw can I set annotations for VMs using PowerCLI..