Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

writing out to file

266 views
Skip to first unread message

Braden C. Roberson-Mailloux

unread,
May 16, 2008, 4:56:13 PM5/16/08
to
Hello everyone;

I'm writing a one-line to take the recursive contents of a directory and
write its contents out to file with send prefixed in front of the $_.name
object.

It goes like this:

dir -recurse | ForEach-Object { write-host send $_name } | Out-File
ftp_batch.txt

but it does not write to file.

Any pointers?


Keith Hill [MVP]

unread,
May 16, 2008, 7:55:41 PM5/16/08
to
"Braden C. Roberson-Mailloux" <br...@vom.com> wrote in message
news:#Z$oFd5tI...@TK2MSFTNGP04.phx.gbl...

First you don't want to use Write-Host since that writes directly to the
host's UI and can't be redirected to a file using Out-File or >. You want
to use Write-Output instead. Second, you are missing a '.' between $_ and
name. Finally since you want to put the "send" and the name on the same line
you should do this:

dir -r | foreach { "send $($_.name)" } > ftp_batch.txt

Note that when PowerShell sees a string like "send $($_.name)" it implicitly
outputs it just as if you had written - write-output "send $($_.name)".

--
Keith

Braden C. Roberson-Mailloux

unread,
May 18, 2008, 2:12:08 PM5/18/08
to
It works. Awesome.
"Keith Hill [MVP]" <r_keit...@mailhot.moc_no_spam_I> wrote in message
news:8882F6B5-7458-4648...@microsoft.com...

Braden C. Roberson-Mailloux

unread,
May 18, 2008, 2:11:55 PM5/18/08
to
Thanks for the response, Keith. I'll give this a shot and report back.

"Keith Hill [MVP]" <r_keit...@mailhot.moc_no_spam_I> wrote in message
news:8882F6B5-7458-4648...@microsoft.com...

0 new messages