Windows Vista Forums
Vista Forums Home Join Vista Forums Donate Vista Tutorials Tags

Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
Register at Vista forums...the world biggest Windows Vista resource Join Vista Forums Now

Go Back   Vista Forums > Microsoft Technical Newsgroups > PowerShell

out-file

Update your Vista Drivers Update Your Drivers Now!!
Closed Thread
 
Thread Tools Display Modes
Old 01-02-2008   #1 (permalink)
IT Staff
Guest


 

out-file

write-host $computer "(Not found)" "`r" | out-file -filepath
D:\results.txt -append

how come the file is empty ?




My System SpecsSystem Spec
Old 01-03-2008   #2 (permalink)
MichielV
Guest


 

RE: out-file

Write-host writes to the console and has no output. Please try:

"$computer (Not found)`r" | out-file -filepath D:\results.txt -append

regards

Michiel


"IT Staff" wrote:
Quote:

> write-host $computer "(Not found)" "`r" | out-file -filepath
> D:\results.txt -append
>
> how come the file is empty ?
>
>
>
>
My System SpecsSystem Spec
Old 01-03-2008   #3 (permalink)
Shay Levi
Guest


 

Re: out-file


Either you write to the console or to the file. If you need to write to both,
use tee-object:

"$computer (Not found)`r" | tee-object -filepath D:\results.txt



-----
Shay Levi
$cript Fanatic
http://scriptolog.blogspot.com
Hebrew weblog: http://blogs.microsoft.co.il/blogs/scriptfanatic


Quote:

> write-host $computer "(Not found)" "`r" | out-file -filepath
> D:\results.txt -append
>
> how come the file is empty ?
>

My System SpecsSystem Spec
Old 01-03-2008   #4 (permalink)
IT Staff
Guest


 

Re: out-file

using tee-object does not have append parameter ?


"MichielV" <MichielV@xxxxxx> wrote in message
news:3D5B470A-271D-469F-9A75-C00D3718B61A@xxxxxx
Quote:

> Write-host writes to the console and has no output. Please try:
>
> "$computer (Not found)`r" | out-file -filepath D:\results.txt -append
>
> regards
>
> Michiel
>
>
> "IT Staff" wrote:
>
Quote:

>> write-host $computer "(Not found)" "`r" | out-file -filepath
>> D:\results.txt -append
>>
>> how come the file is empty ?
>>
>>
>>
>>

My System SpecsSystem Spec
Old 01-03-2008   #5 (permalink)
Shay Levi
Guest


 

Re: out-file

No. You can write a function to mimic its behaviour:


function Write-ToConsoleAndFile($path,$text){
write-host $text
out-file -filepath $path -inputObject $text -encoding ASCII -append -force

}


$computers = "box1","box2","box3"
$computers | foreach { Write-ToConsoleAndFile D:\results.txt "$_ (Not Found)"
}



-----
Shay Levi
$cript Fanatic
http://scriptolog.blogspot.com
Hebrew weblog: http://blogs.microsoft.co.il/blogs/scriptfanatic


Quote:

> using tee-object does not have append parameter ?
>
> "MichielV" <MichielV@xxxxxx> wrote in message
> news:3D5B470A-271D-469F-9A75-C00D3718B61A@xxxxxx
>
Quote:

>> Write-host writes to the console and has no output. Please try:
>>
>> "$computer (Not found)`r" | out-file -filepath D:\results.txt -append
>>
>> regards
>>
>> Michiel
>>
>> "IT Staff" wrote:
>>
Quote:

>>> write-host $computer "(Not found)" "`r" | out-file -filepath
>>> D:\results.txt -append
>>>
>>> how come the file is empty ?
>>>

My System SpecsSystem Spec
Closed Thread

Thread Tools
Display Modes



Similar Threads
Thread Thread Starter Forum Replies Last Post
Scheduled task (run .bat file) fails every time with 0x80070002 (file not found) Ben Dilts Vista General 2 07-22-2008 08:50 AM
Create New folder, move file, delete file. Explorer Freeze erod49 General Discussion 10 05-20-2008 05:38 AM
file icons dont match contents-file names hidden Fosbury Vista file management 0 05-07-2008 05:48 PM
coping file from a remote file share - FILE IS NO LONG THERE bogus error message Heith Vista networking & sharing 0 10-18-2007 03:58 PM
File Open and File Save As Dialog Freeze and Hang All Applications =?Utf-8?B?TGlnaHRmb290ZQ==?= Vista file management 0 07-12-2006 11:39 AM


Vistax64.com is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media 2005-2008

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51