VMware Cloud Community
ganapa2000
Hot Shot
Hot Shot
Jump to solution

Import particular row data from csv

Hi,

I am having issues importing particular row data from csv, please help

Below is the contents of my csv

Team,CPU,Memory

HR,100,50

DEV,200,150

OPS,100,80

Code

$vmlist = Import-CSV "D:\import.csv"

$vmlist | where Team = HR

$vmlist.CPU

$vmlist.Memory

Error

Where-Object : A positional parameter cannot be found that accepts argument 'System.Object[]'.

At D:\import1.ps1:2 char:11

+ $vmlist | where $vmlist.Team = HR

+           ~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : InvalidArgument: (:) [Where-Object], ParameterBindingException

    + FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.WhereObjectCommand

Reply
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Try like this

Import-CSV "D:\import.csv" |

where{$_.Team -eq 'HR'} |

Select Cpu,Memory


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

View solution in original post

Reply
0 Kudos
3 Replies
LucD
Leadership
Leadership
Jump to solution

Try like this

Import-CSV "D:\import.csv" |

where{$_.Team -eq 'HR'} |

Select Cpu,Memory


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

Reply
0 Kudos
Sivaramsharmar
Enthusiast
Enthusiast
Jump to solution

You may try as below

$vmlist = Import-CSV "D:\import.csv"

$vmlist | ?{$_.team -eq "HR"} | select CPU,Memory

Reply
0 Kudos
ganapa2000
Hot Shot
Hot Shot
Jump to solution

superb, that was quick and perfect. Thank you very much Smiley Happy

Reply
0 Kudos