John Darby
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
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks!
ASKER
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.