ganapa2000
Hot Shot
Hot Shot

Import particular row data from csv

Jump to solution

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

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership

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

0 Kudos
3 Replies
LucD
Leadership
Leadership

Try like this

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

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

Select Cpu,Memory


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

0 Kudos
Sivaramsharmar
Enthusiast
Enthusiast

You may try as below

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

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

0 Kudos
ganapa2000
Hot Shot
Hot Shot

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

0 Kudos