![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | new line in text file with out-file Hi, $server = "server1" $event = "event1" $ip = "100.10.100.1" I want to see in file text file: server1 event1 100.10.100.1 So I tryed to create var and use it with out-host like this $to_file = "`n$server + `n$event + `n$ip" out- file -filepath c:\log1.log -append -inputobject $to_file It's doesn't working. Please help. Didi |
My System Specs![]() |
| | #2 (permalink) |
| | Re: new line in text file with out-file On Jun 20, 6:50 am, Did <didi10...@walla.co.il> wrote: > I want to see in file text file: > > server1 > event1 > 100.10.100.1 Try this: $out = @" $server $event $ip "@ example: 40# $server = "my server" ; $event = "test event" ; $ip = "10.2.1.11" 41# $out=@" >> $server >> $event >> $ip >> "@ >> 42# $out my server test event 10.2.1.11 |
My System Specs![]() |
| | #3 (permalink) |
| | Re: new line in text file with out-file "Did" <didi10000@walla.co.il> wrote in message news:1182336636.168062.115650@m36g2000hse.googlegroups.com... > Hi, > > $server = "server1" > $event = "event1" > $ip = "100.10.100.1" > > I want to see in file text file: > > server1 > event1 > 100.10.100.1 > > So I tryed to create var and use it with out-host like this > > $to_file = "`n$server + `n$event + `n$ip" You are not doing the concatenation right. You are enclosing the variables with double quotes which will automatically concatenate them for you, so you do not need to concatenate them with a + sign. This should work: $to_file = "$server`n$event`n$ip" In addition, I think there is a bug with "`n" being doubled in some circumstances. E.g. if you start or finish your string with a "`n" it will show as two blank lines. In your case, if you want to have an empty line before your text you can work around it like this: $to_file = " `n$server`n$event`n$ip" Note the space before the first "`n"... And finally, if you really do need an *empty* line, you can follow the space with the backspace character which will delete it (as if you had pressed Backspace on your keyboard): $to_file = " `b`n$server`n$event`n$ip" Hope that helps :-) Jacques |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Unable to Create New Line in Text File | PowerShell | |||
| How to read the LAST NON-BLANK line from a text file? | VB Script | |||
| Read a line from a text file, without loading the entire file inmemory | PowerShell | |||
| How to remove blanks line from a text outpu file | PowerShell | |||
| The next line in a text file | PowerShell | |||