Link to home
Start Free TrialLog in
Avatar of John Darby
John DarbyFlag for United States of America

asked on

Read txt file using powershell to feed a command

Greetings!

I have a command I want to feed a variable from a txt file. The command is...

kerblist get ldap/$variablename

The textfile is named  .\sitedcs.txt

The txt file will have 3-8 entries which are hostnames for the local site DCs.

I remember the FOR loop from the CMD shell days, but am sure there is a better way within native PS.

TIA!
JohnD
ASKER CERTIFIED SOLUTION
Avatar of Adam Brown
Adam Brown
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of John Darby

ASKER

Thanks acbrown2010!

Here is your suggestion in txt...

import-csv .\sitedcs.csv | foreach {kerblist get ldap/???}

My question is how I populate the ??? part which should hold the hostname which is derived from the CSV list? There are 3-8 of these values.
Thanks!