0

I'm trying to make list of kb in folder and add to results some additional text. Im trying like that, but its not like I want:

    $nazwa = Get-ChildItem -file "c:\2012 standart\" | select name 

     for($a=1 ; $a -le $nazwa.Length; $a++)
     {
      "start"
     "$nazwa[$a]"+"addiotional text"
     "stop"
      }

I would like results like that:

start

file1 additional text
file2 additional text
file3 additional text

stop

Where is the problem? Will be great grateful for any help.

1 Answer 1

1
write-host "start"
$nazwa=Get-ChildItem -file "c:\temp\" |  select-object name 

foreach ($i in $nazwa  )
{
    write-host $i.name "addiotional text"
}
write-host "end"
Sign up to request clarification or add additional context in comments.

3 Comments

@Czajnik: Please accept János' answer, if it helped you.
@János How to redirect this output to file? I try .\generator.ps1 > list.txt, file is created but without outputs (empty), any idea?
$FileToWrite="C:\temp\test.txt" "start" > $FileToWrite $nazwa=Get-ChildItem -file "c:\temp\" | select-object name foreach ($i in $nazwa ) { $text=$i.name + "addiotional text" $text>> $FileToWrite } "end" >> $FileToWrite

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.