VMware Cloud Community
mdangel1
Enthusiast
Enthusiast
Jump to solution

need to pull data from csv

Hello all,

 

I need help with pulling VMs from a csv and then run the following script

 

Get-VM | Select Name, @{N="Datastore";E={$_ | Get-Datastore}}

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

You mean something like this?

# CSV layout 
#
# Name
# vm1
# vm2

Import-Csv -Path .\vmnames.csv -PipelineVariable row |
ForEach-Object -Process {
    Get-VM -Name $row.Name | 
    Select Name, @{N="Datastore";E={($_ | Get-Datastore).Name}}
}


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

View solution in original post

0 Kudos
2 Replies
LucD
Leadership
Leadership
Jump to solution

You mean something like this?

# CSV layout 
#
# Name
# vm1
# vm2

Import-Csv -Path .\vmnames.csv -PipelineVariable row |
ForEach-Object -Process {
    Get-VM -Name $row.Name | 
    Select Name, @{N="Datastore";E={($_ | Get-Datastore).Name}}
}


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

0 Kudos
mdangel1
Enthusiast
Enthusiast
Jump to solution

Exactly!  Thank you

0 Kudos