![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| 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) |
| | 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 Specs![]() |
| | #2 (permalink) |
| | 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 Specs![]() |
| | #3 (permalink) |
| | 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 Specs![]() |
| | #4 (permalink) |
| | 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 Specs![]() |
| | #5 (permalink) |
| | 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 Specs![]() |
| | #6 (permalink) |
| | 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 Specs![]() |
| | #7 (permalink) |
| | 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 Specs![]() |
| | #8 (permalink) |
| | 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 Specs![]() |
![]() |
| Thread Tools | |
| |