Thanks for the quick reply again and Thanks for the great help.
I already removed the quote from the "status".
But when i tried run just below line, I am getting the below error.
<
PowerCLI C:\Scripts> $vm = Get-VM VMname1 if($vm) {$vm.powerstate} else {"Not found"}
Get-VM : A positional parameter cannot be found that accepts argument 'if'.
At line:1 char:13
+ $vm = Get-VM <<<< VMName1 if($vm) {$vm.powerstate} else {"Not found"}
+ CategoryInfo : InvalidArgument: (:) [Get-VM], ParameterBindingException
+ FullyQualifiedErrorId : PositionalParameterNotFound,VMware.VimAutomation.ViCore.Cmdlets.Commands.GetVM
>
Not sure, if it helps you to find what i am doing wrong in the script?