Automation

 View Only
  • 1.  need to pull data from csv

    Posted Apr 22, 2021 11:04 PM

    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}}



  • 2.  RE: need to pull data from csv
    Best Answer

    Posted Apr 23, 2021 06:12 AM

    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}}
    }
    


  • 3.  RE: need to pull data from csv

    Posted Apr 23, 2021 10:40 AM

    Exactly!  Thank you