how to handle - import-csv results

Dear experts
I have this command $Items = Import-Csv -path "$CsvFile" -Encoding UTF8 –delimiter ";"

This work pretty well so I can access the collection by having the fieldnames etc.... ($Items.<fieldname> is OK)

BUT how to have a global view ? How to know for $Items, the number of elements?


Tks.
François VDCIcT service DeskAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

oBdACommented:
$Items.Count

Open in new window

1
François VDCIcT service DeskAuthor Commented:
$items.count return nothing.

 write-host $items
@{IDENTIFIANT=900000003; TITLE_CODE=; TITLE_NAME=; CONTRAT_NB=900000003; NAME=AO; FIRSTNAME=Stagiaire; SEXE=; NATIONAL_ID=; STREET=; STREET_NR=; STREET_BOX=; CITYCODE=; CITY NAME=; COUNTRY NAME=; PHONE_PROF=; GSM_PROF=; EMAIL_PROF=stAO@daoust.be; BIRTHDATE=; NATIONALITY NAME=; LANG=; WORKERLANG NAME=; TRY_DATE=; ENTRY_DATE=20171130; OUT_DATE=; CONTRAT_TYPE=; CONTRAT_TYPE_NAME=; FTE=; FUNCTION=Stagiaire; AGE=; CODE_DEPARTEMENT=; DEPARTEMENT=; IDENTIFIANT_RESPONSABLE=; LOGIN_RESPONSABLE=sgoossens; RESPONSABLE=; LOGIN=stao; CODE_EMPLOYEUR=51300; CODE_SITE=AO; SITE=; EmployeeName=Stagiaire AO; SignaletiqueInsert=20171130; SignaletiqueUpdate=; AddressInsert=; AddressUpdate=; AffectationInsert=; AffectationUpdate=; ContractInsert=; ContractUpdate=; GAP=; Matchbox=; SMILE=; Intranet=; Desktop=; Laptop=; Carte_De_visite=; telephone=; GSM=; Smartphone=; Signal=; VPN=; clee_jobcenter=; ProxBudget=; Analytique1Code=; Analytique2Code=; IN=TRUE; OUT=}

write-host $items.count

return nothing
0
QlemoBatchelor, Developer and EE Topic AdvisorCommented:
And of course you can just dump everything with $items | format-table -auto or $items | format-list, to see what is in the collection.
0
Has Powershell sent you back into the Stone Age?

If managing Active Directory using Windows Powershell® is making you feel like you stepped back in time, you are not alone.  For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why.

QlemoBatchelor, Developer and EE Topic AdvisorCommented:
That is a single object, no collection. @($Items).Count works though. It forces the content to be an array, and that array always has a Count member.
0
François VDCIcT service DeskAuthor Commented:
yes indeed Qlemo, but I want to have the number of items on this collection/hashtable what is this object.
0
François VDCIcT service DeskAuthor Commented:
@($Items).Count report 1 not the count of all elements....
0
QlemoBatchelor, Developer and EE Topic AdvisorCommented:
That is a different beast. You want to know the number of (custom) properties of that custom object ...
A hashtable would allow for counting, e.g. @{a=1;b=2}.Count.
0
François VDCIcT service DeskAuthor Commented:
Ok. I'm still lost....
how may I know the number of custom properties that has a custom object? (from the import-csv cmdlet) Purpose is dataquality check (see if I have the number of col that I expect)
0
QlemoBatchelor, Developer and EE Topic AdvisorCommented:
Here you go: @($items.PsObject.Properties).count
The hidden PsObject property allows for direct access to the underlaying object structure.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
François VDCIcT service DeskAuthor Commented:
Your'e brillant !
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Powershell

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.