Get-VM working anymore?

This post was originally published on this site

I have a few scripts that seem to just not be working anymore.  I basically just want to feed a list of VMs using get-content and I want the output to be the VM name and the Folder name. I am not great at scripting but this has been typically easy and something I have done in the past.




# vCenters to connect to

    $hosts = @(





# Connect to both vCenters

# Connect-VIServer -Server $hosts


$list = Get-Content -Path C:xxxxxxxxx.txt


Get-VM -Name $list -Server $hosts |

Select Name , Folder | sort Folder | ft -AutoSize






#Connect-VIServer xxxxxxxxxxxxx


$list = Get-Content -Path C:xxxxxxxxxxxxxx.txt


    foreach($vm in $list){


    Get-VM -Name $vm |


    Select Name,


    @{N=”Folder”;E={$_.Folder.Name}} | export-csv c:xxxxxxxvmname.csv




If i do just get-vm it works no problem its ignoring the list, these two scripts have worked no issue for a long time now any help is appreciated.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.