Gmail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Files created by Powershell are over 2X bigger than files created by text editor or cmd.exe.
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  5 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
tom.lux...@gmail.com  
View profile  
 More options May 16 2008, 12:07 pm
Newsgroups: microsoft.public.windows.powershell
From: tom.lux...@gmail.com
Date: Fri, 16 May 2008 09:07:41 -0700 (PDT)
Local: Fri, May 16 2008 12:07 pm
Subject: Files created by Powershell are over 2X bigger than files created by text editor or cmd.exe.
I'm trying to build telnet scripts using Powershell and run them with
the Telnet Script Tool (TST) but files created by Powershell are not
recognized as valid text/script files by TST.

I discovered files generated by Powershell are more than twice the
size of plain text files created outside of Powershell.

Here is the test:
[PowerShell]
"test"> test.a

[Cmd.exe]
echo test> test.b

A 'dir' of these files from a shell reveals:
05/16/2008  09:34 AM                14 test.a
05/16/2008  09:34 AM                 6 test.b

*Notice the size of the files.

What's going on?  The test.b file is appropriately 6 bytes: "test\r\n"
= 6 chars.  Where are the extra 8 chars coming from in the PS-created
file?

The files in any text editor appear identical and Textpad said they
were identical as well.

Then I opened a PS-created file in MS Word 2007 and saw non-printable
chars before each char in the file.

Please help.  Thx.


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Karl Mitschke  
View profile  
 More options May 16 2008, 12:14 pm
Newsgroups: microsoft.public.windows.powershell
From: Karl Mitschke <kmitsc...@somestate.gov>
Date: Fri, 16 May 2008 16:14:42 +0000 (UTC)
Local: Fri, May 16 2008 12:14 pm
Subject: Re: Files created by Powershell are over 2X bigger than files created by text editor or cmd.exe.
Hello tom,

It's not outputting in ASCII. (I beleive it's unicode)

Do this:

"test" |out-file -Encoding ascii test.c

Karl


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
tom.lux...@gmail.com  
View profile  
 More options May 16 2008, 12:36 pm
Newsgroups: microsoft.public.windows.powershell
From: tom.lux...@gmail.com
Date: Fri, 16 May 2008 09:36:51 -0700 (PDT)
Local: Fri, May 16 2008 12:36 pm
Subject: Re: Files created by Powershell are over 2X bigger than files created by text editor or cmd.exe.
That did the trick!  Thank you Karl.

I was starting to go down that path (unicode vs. ascii), but hadn't
nailed it yet.

Can I make ASCII the default output encoding?  Is this wise?

Something that threw me off is $OutputEncoding.  Why doesn't
$OutputEncoding show Unicode?

PS C:\> $OutputEncoding
IsSingleByte      : True
BodyName          : us-ascii
EncodingName      : US-ASCII
HeaderName        : us-ascii
WebName           : us-ascii
WindowsCodePage   : 1252
IsBrowserDisplay  : False
IsBrowserSave     : False
IsMailNewsDisplay : True
IsMailNewsSave    : True
EncoderFallback   : System.Text.EncoderReplacementFallback
DecoderFallback   : System.Text.DecoderReplacementFallback
IsReadOnly        : True
CodePage          : 20127


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Karl Mitschke  
View profile  
 More options May 16 2008, 3:13 pm
Newsgroups: microsoft.public.windows.powershell
From: Karl Mitschke <kmitsc...@somestate.gov>
Date: Fri, 16 May 2008 19:13:03 +0000 (UTC)
Local: Fri, May 16 2008 3:13 pm
Subject: Re: Files created by Powershell are over 2X bigger than files created by text editor or cmd.exe.
Tom;

I have no idea, and i have no idea :)


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
alexandair  
View profile  
 More options May 27 2008, 6:06 am
Newsgroups: microsoft.public.windows.powershell
From: alexandair <alexand...@gmail.com>
Date: Tue, 27 May 2008 03:06:13 -0700 (PDT)
Local: Tues, May 27 2008 6:06 am
Subject: Re: Files created by Powershell are over 2X bigger than files created by text editor or cmd.exe.
On May 16, 6:36 pm, tom.lux...@gmail.com wrote:

There are two major ways to write files in PowerShell — with the Out-
File cmdlet and using the Set-Content cmdlet. Out-File will try to
format the output and text files are written in Unicode by default. We
can change that with -encoding parameter. Set-Content will simply
write the output and use ASCII encoding.

Also, when we pipe output data from PowerShell cmdlets into native
applications, the output encoding from PowerShell cmdlets is
controlled by the $OutputEncoding variable, which is by default set to
ASCII. You could find more details here:
http://blogs.msdn.com/powershell/archive/2006/12/11/outputencoding-to...

-aleksandar
http://powershellers.blogspot.com


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google