VMware Cloud Community
tdubb123
Expert
Expert

show VMs in a list of datastores

I need to show all vms in a list of datastores

get-content luns.txt | % { get-datastore -name $_ | get- vm}

it shows nothing

am i gettin this right?

0 Kudos
5 Replies
LucD
Leadership
Leadership

How does that luns.txt file look?

A single datastorename per line, no blank lines?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
tdubb123
Expert
Expert

yes one datastore per line.

I am trying to unmount the datastores and delete them with this

get-content luns.txt | % {get-datastore -name $_ | unmount-datastore }

but seems like it going forever in a loop?

0 Kudos
LucD
Leadership
Leadership

Is this showing one datastorename per line?

Get-Content -Path luns.txt


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
tdubb123
Expert
Expert

yes

0 Kudos
LucD
Leadership
Leadership

What is this Unmount-Datastore?

Is that the function from Datastore Mount/Unmount Detach/Attach functions?

Let's take this step-by-step

What does this return

Get-Content -Path luns.txt

And this?

Does it return all the datastores in luns.txt?

Get-Content -Path luns.txt | %{

    Get-Datastore -Name $_

}


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos