Automation

 View Only
  • 1.  -ExpandProperty importing data from CSV file

    Posted May 18, 2020 02:53 PM
    $VMlist = Import-Csv -Path /temp/5192020.csv -UseCulture | select -ExpandProperty Name

    Get-VM -Name $VMlist | where {$_.PowerState -eq "PoweredOn"}

    I have Name in my first column, first cell and the list of VM's below this in the .csv file  I get this error..  Am I trying to use something that's been deprecated?

    Get-VM -Name $VMlist | where {$_.PowerState -eq "PoweredOn"}

         |               ~~~~~~~

         | Cannot validate argument on parameter 'Name'. The argument is null, empty, or an element of the argument collection contains a null value. Supply a collection that does not contain any null

         | values and then try the command again.

    Thanks..



  • 2.  RE: -ExpandProperty importing data from CSV file
    Best Answer

    Posted May 18, 2020 03:07 PM

    What does the Import-Csv return?

    Import-Csv -Path /temp/5192020.csv -UseCulture



  • 3.  RE: -ExpandProperty importing data from CSV file

    Posted May 18, 2020 06:35 PM

    It would read it but not display anything, same thing happens on a bunch of my CSV files.  I created some new ones and it's working fine, must have some hidden formatting in there or something..

    Thanks.