You could use something like grep to extract it but you could also add the following in your powershell script
`
Select-Object -ExpandProperty Name
`
This must come after your Get-* cmdlet call, i.e. ‘Get-VMs | Select-Object -ExpandProperty Name’. This works by taking in the output from the cmdlet and outputting only the values of the Name property.
It worked for some extent , now iam getting the o/p as below. Actually i am new to PowerCLI so dont have much idea on PowerCLi cmdlets, But is there a way to remove the inverted commas and Comma using the PowerCLi Commad.
Actually the Vcenter in my organisation has policy enforced not have SSL connectivity , so i cld nt use ansible vm-modules . That is why i had to switch to PWSH using ansible.
Jordan’s Suggestion worked . But i need to figure out how to remove special characters from o/p using PowerCLi cmds