VMware Cloud Community
Gaprofitt17
Enthusiast
Enthusiast
Jump to solution

-ExpandProperty importing data from CSV file

$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..

Reply
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

What does the Import-Csv return?

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


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

View solution in original post

Reply
0 Kudos
2 Replies
LucD
Leadership
Leadership
Jump to solution

What does the Import-Csv return?

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


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

Reply
0 Kudos
Gaprofitt17
Enthusiast
Enthusiast
Jump to solution

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.

Reply
0 Kudos