Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
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.

Go Back   Vista Forums > Misc Newsgroups > PowerShell

Vista - add-content bug?

Reply
 
Old 05-23-2006   #1 (permalink)
Andrew Watt [MVP]


 
 

add-content bug?

Can anyone else repro this?

I created a simple script to explore Staffan's questions (one on this
newsgroup, one elsewhere):

It contained:

write-host "This the calling script";
SubFolder\Date # Date is Date.ps1 in the SubFolder folder

I then used add-content to attempt to add another command, Rightly or
wrongly, I began it with a semi-colon:

add-content -Path Calling.ps1 -Value "; write-host 'Back in
Calling.ps1'."

I got an error when running Calling.ps1 similar to the following:

PS C:\PowerShellScripts> .\Calling
This is the calling script

23 May 2006 17:16:05
C:\PowerShellScripts\Calling.ps1
'??????????????????' is not recognized as a cmdlet, function, operable
program,
or script file.
At C:\PowerShellScripts\Calling.ps1:2 char:18
+ ?????????????????? <<<<


Opening the script in Notepad I see multiple rectangles for characters
where I had expected to see the text added using the -Value parameter
of add-content.

Is this reproducible by anyone else? Does anyone understand why?

Bug??

Thanks

Andrew Watt MVP

My System SpecsSystem Spec
Old 05-23-2006   #2 (permalink)
Keith Hill [MVP]


 
 

Re: add-content bug?

"Andrew Watt [MVP]" <SVGDeveloper@aol.com> wrote in message
news:csc672hbog2um54q77bnbgphs6bhhuoq0b@4ax.com...
> Can anyone else repro this?


Yes and no. If I redirect to a file and get unicode encoding then do the
add-content I see the error. If I open up notepad and create the initial
script as an ASCII file and then do the add-content, it works fine.

--
Keith


My System SpecsSystem Spec
Old 05-23-2006   #3 (permalink)
DBMwS


 
 

Re: add-content bug?

Oh yeah, I was able to create a text file on windows explorer and then tried
"add-content" and i was able to append commands to Calling.ps1 in ASCII
format.

BTW, i didn't have to create a file through notepad, but that i had to
supply "ASCII" encoding option to "out-file" while creating a new file in
PowerShell


[^_^]PS[368]>'write-host "calling3.ps1"' | Out-File -Encoding ascii
Calling3.ps1

[^_^]PS[369]>type Calling3.ps1
write-host "calling3.ps1"
[^_^]PS[370]>Add-Content -Path .\calling3.ps1 -value '; write-host "Back in
Call
ing.ps1"'
[^_^]PS[371]>type Calling3.ps1
write-host "calling3.ps1"
; write-host "Back in Calling.ps1"


"Keith Hill [MVP]" wrote:

> "Andrew Watt [MVP]" <SVGDeveloper@aol.com> wrote in message
> news:csc672hbog2um54q77bnbgphs6bhhuoq0b@4ax.com...
> > Can anyone else repro this?

>
> Yes and no. If I redirect to a file and get unicode encoding then do the
> add-content I see the error. If I open up notepad and create the initial
> script as an ASCII file and then do the add-content, it works fine.
>
> --
> Keith
>
>
>

My System SpecsSystem Spec
Old 05-23-2006   #4 (permalink)
DBMwS


 
 

RE: add-content bug?

I was able to reproduce the error and I am assuming the reason for the error
being that

On Newsgroup
http://www.microsoft.com/communities...xp=&sloc=en-us

James Truher mentioned that "in previous drops, when redirecting output to a
file, we did so in ASCII. With RC1, we changed this to UNICODE". Maybe the
problem is that, when you "add-content" to Calling.ps1, it is added to the
script file in UNICODE format, making the added content look like mess.

BTW, I think you had posted on that Newsgroup with a comment, "It seems to
me that you will need Unicode for internationalisation in any case"

"Andrew Watt [MVP]" wrote:

> Can anyone else repro this?
>
> I created a simple script to explore Staffan's questions (one on this
> newsgroup, one elsewhere):
>
> It contained:
>
> write-host "This the calling script";
> SubFolder\Date # Date is Date.ps1 in the SubFolder folder
>
> I then used add-content to attempt to add another command, Rightly or
> wrongly, I began it with a semi-colon:
>
> add-content -Path Calling.ps1 -Value "; write-host 'Back in
> Calling.ps1'."
>
> I got an error when running Calling.ps1 similar to the following:
>
> PS C:\PowerShellScripts> .\Calling
> This is the calling script
>
> 23 May 2006 17:16:05
> C:\PowerShellScripts\Calling.ps1
> '??????????????????' is not recognized as a cmdlet, function, operable
> program,
> or script file.
> At C:\PowerShellScripts\Calling.ps1:2 char:18
> + ?????????????????? <<<<
>
>
> Opening the script in Notepad I see multiple rectangles for characters
> where I had expected to see the text added using the -Value parameter
> of add-content.
>
> Is this reproducible by anyone else? Does anyone understand why?
>
> Bug??
>
> Thanks
>
> Andrew Watt MVP
>

My System SpecsSystem Spec
Old 05-23-2006   #5 (permalink)
Andrew Watt [MVP]


 
 

Re: add-content bug?

On Tue, 23 May 2006 10:41:27 -0600, "Keith Hill [MVP]"
<r_keith_hill@no.spam.thank.u.hotmail.com> wrote:

>"Andrew Watt [MVP]" <SVGDeveloper@aol.com> wrote in message
>news:csc672hbog2um54q77bnbgphs6bhhuoq0b@4ax.com...
>> Can anyone else repro this?

>
>Yes and no. If I redirect to a file and get unicode encoding then do the
>add-content I see the error. If I open up notepad and create the initial
>script as an ASCII file and then do the add-content, it works fine.


Thanks, Keith.

Yes, I created the initial script using redirection. That part of the
file opened ok in Notepad.

But adding content using add-content caused a problem.

Surely they should work together without these problems?

I've bugged it at
https://connect.microsoft.com/feedba...edbackID=78800.

Andrew Watt MVP
My System SpecsSystem Spec
Old 05-23-2006   #6 (permalink)
Andrew Watt [MVP]


 
 

Re: add-content bug?

On Tue, 23 May 2006 09:59:38 -0700, DBMwS
<DBMwS@discussions.microsoft.com> wrote:

>BTW, I think you had posted on that Newsgroup with a comment, "It seems to
>me that you will need Unicode for internationalisation in any case"


<grin/> ... Yes I remember writing that!

And that's still true, I think.

However ...

Having individual commands in a single PowerShell installation that
send ASCII or Unicode to a script file and mix them up isn't a way to
go.

I also did suggest that some sort of global variable be added to give
the user control of encoding. And I still think that.

Andrew Watt MVP
My System SpecsSystem Spec
Old 05-23-2006   #7 (permalink)
/\\/\\o\\/\\/


 
 

Re: add-content bug?

again here same problem I had with import-csv,
PowerShell created Unicode but could not read it again.

so I still say ASCI standard, or do a compleet recheck on the UniCode
support in powershell(with the current console good luck ;-)

Andrew Watt [MVP] wrote:
> On Tue, 23 May 2006 09:59:38 -0700, DBMwS
> <DBMwS@discussions.microsoft.com> wrote:
>
>> BTW, I think you had posted on that Newsgroup with a comment, "It seems to
>> me that you will need Unicode for internationalisation in any case"

>
> <grin/> ... Yes I remember writing that!
>
> And that's still true, I think.
>
> However ...
>
> Having individual commands in a single PowerShell installation that
> send ASCII or Unicode to a script file and mix them up isn't a way to
> go.
>
> I also did suggest that some sort of global variable be added to give
> the user control of encoding. And I still think that.
>
> Andrew Watt MVP

My System SpecsSystem Spec
Old 05-23-2006   #8 (permalink)
DBMwS


 
 

Re: add-content bug?

"Andrew Watt [MVP]" wrote:

> I also did suggest that some sort of global variable be added to give
> the user control of encoding. And I still think that.
>


Yeah, i think it would make sense to be able to set a global encoding option
or at least add "-Encoding" option to all the cmdlets that reads/writes
data(just like there is an "-Encoding" option in Out-File cmdlet)
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Set-Content not updating file after get-content and forEach-Object PowerShell
EMC and Microsoft Form New Enterprise Content Management Alliance, Extend Microsoft Office SharePoint Server With Content, Compliance and Archive Solutions Vista News
Issue: getting/setting variable content using Get/Set-Content PowerShell
Weirdness with get-content | replace | set-content - file content is deleted!! PowerShell


Vista Forums 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 Ltd

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