Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

Powershell - loop question

$
0
0

I have a script which is visible in the screenshot and I don't know why the values in $vmlist cannot be accessed.
I'm creating the list, then foreach"ing" them, but running a command against them is erroring out on each loop.
HyperVisor cannot find machine name. I can assure you the machine names are correct.

I think it's a result of the Type of list created for $vmList (ie.. not true text...??)

$vmlist=Get-VM | Where State -eq Running | Select Name
if ($vmlist) {
  foreach ($vmname in $vmlist) {
        Stop-VM -name $vmname 
}}


Can anyone help?



Viewing all articles
Browse latest Browse all 15028

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>