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 - Re: exchange shell escape character

Reply
 
Old 10-12-2007   #1 (permalink)
Bob Butler


 
 

Re: exchange shell escape character

Just a bump and addition of the powershell group to see if anybody knows
about this

"Bob Butler" <noway@xxxxxx> wrote in message
news:eABSl0DDIHA.5024@xxxxxx
Quote:

> I've just started playing with the exchange shell for Exchange 2007 and
> ran into something odd. In straight Powershell I can write a line like
> $t = "line1`r`nline2"
> and it will create a string with a CR/LF sequence in the middle. In the
> Exchange Management Shell, which I thought was essentially Powershell,
> that doesn't work. The backtick character no longer acts as an esacpe
> sequence for special characters and I haven't been able to find any
> mention of this change anywhere.
>
> Does anybody know if there is an alternative besides defining characters
> using ([char]x)?
>


My System SpecsSystem Spec
Old 10-12-2007   #2 (permalink)
Shay Levi


 
 

Re: exchange shell escape character


Hi

I launched Exchange Management Shell and ran

PS > $t = "line1`r`nline2"
PS > $t
line1
line2

In "straight Powershell" the output is the same.

PS > $t = "line1`r`nline2"
PS > $t
line1
line2

What happens when you run

PS C:\Scripts> "`$pwd=$pwd"
$pwd=C:\Scripts

Do you get the same ($pwd=your working directory path)?

Shay
http://scriptolog.blogspot.com


Quote:

> Just a bump and addition of the powershell group to see if anybody
> knows about this
>
> "Bob Butler" <noway@xxxxxx> wrote in message
> news:eABSl0DDIHA.5024@xxxxxx
>
Quote:

>> I've just started playing with the exchange shell for Exchange 2007
>> and
>> ran into something odd. In straight Powershell I can write a line
>> like
>> $t = "line1`r`nline2"
>> and it will create a string with a CR/LF sequence in the middle. In
>> the
>> Exchange Management Shell, which I thought was essentially
>> Powershell,
>> that doesn't work. The backtick character no longer acts as an
>> esacpe
>> sequence for special characters and I haven't been able to find any
>> mention of this change anywhere.
>> Does anybody know if there is an alternative besides defining
>> characters using ([char]x)?
>>

My System SpecsSystem Spec
Old 10-12-2007   #3 (permalink)
Marco Shaw [MVP]


 
 

Re: exchange shell escape character

Quote:
Quote:

>> and it will create a string with a CR/LF sequence in the middle. In
>> the Exchange Management Shell, which I thought was essentially
>> Powershell, that doesn't work. The backtick character no longer acts
>> as an esacpe sequence for special characters and I haven't been able
>> to find any mention of this change anywhere.
This is from the Exchange 2007 shell in my VM:

[PS] >$t = "line1`r`nline2"
[PS] >$t
line1
line2

You're not seeing the same?

Well, the Exchange shell is PowerShell, but with a few addons. Here's
what starts the Exchange shell:
C:\WINDOWS\system32\WindowsPowerShell\v1.0\PowerShell.exe -PSConsoleFile
"C:\Program Files\Microsoft\Exchange Server\bin\exshell.psc1" -noexit
-command ". 'C:\Program Files\Microsoft\Exchange Server\bin\Exchange.ps1'"

Marco

--
Microsoft MVP - Windows PowerShell
http://www.microsoft.com/mvp

PowerGadgets MVP
http://www.powergadgets.com/mvp

Blog:
http://marcoshaw.blogspot.com
My System SpecsSystem Spec
Old 10-12-2007   #4 (permalink)
Bob Butler


 
 

Re: exchange shell escape character

"Shay Levi" <no@xxxxxx> wrote in message
news:8766a94496d98c9db1711d7aec6@xxxxxx
Quote:

>
> Hi
>
> I launched Exchange Management Shell and ran
> PS > $t = "line1`r`nline2"
> PS > $t
> line1
> line2
I spent hours with this yesterday and it would NOT recognize the backtick to
insert special characters in a string literal no matter what I did.

Today it is working perfectly.

Thanks for trying it. If I can figure out what causes it to get screwed up
I'll post back. Until then..... nevermind <g>


My System SpecsSystem Spec
Old 10-12-2007   #5 (permalink)
Bob Butler


 
 

Re: exchange shell escape character

"Marco Shaw [MVP]" <marco.shaw@_NO_SPAM_gmail.com> wrote in message
news:uq78EBPDIHA.2004@xxxxxx
Quote:

>
Quote:
Quote:

>>> and it will create a string with a CR/LF sequence in the middle. In the
>>> Exchange Management Shell, which I thought was essentially Powershell,
>>> that doesn't work. The backtick character no longer acts as an esacpe
>>> sequence for special characters and I haven't been able to find any
>>> mention of this change anywhere.
>
> This is from the Exchange 2007 shell in my VM:
>
> [PS] >$t = "line1`r`nline2"
> [PS] >$t
> line1
> line2
>
> You're not seeing the same?
What I was seeing yesterday was
[PS] >$t
line1`r`nline2

today it is working; same system, same everything, no reboot,... I'll have
to try to figure out what I did yesterday that confused it


My System SpecsSystem Spec
Old 10-12-2007   #6 (permalink)
Shay Levi


 
 

Re: exchange shell escape character

Any other PS Snapins included or "Dot Sourced" Scripts in your EMS profile?
Something that can break/override PowerShell defaults???


Shay
http://scriptolog.blogspot.com


Quote:

> "Shay Levi" <no@xxxxxx> wrote in message
> news:8766a94496d98c9db1711d7aec6@xxxxxx
>
Quote:

>> Hi
>>
>> I launched Exchange Management Shell and ran
>> PS > $t = "line1`r`nline2"
>> PS > $t
>> line1
>> line2
> I spent hours with this yesterday and it would NOT recognize the
> backtick to insert special characters in a string literal no matter
> what I did.
>
> Today it is working perfectly.
>
> Thanks for trying it. If I can figure out what causes it to get
> screwed up I'll post back. Until then..... nevermind <g>
>

My System SpecsSystem Spec
Old 10-12-2007   #7 (permalink)
Shay Levi


 
 

Re: exchange shell escape character

Did you by any chance typed 'line1`r`nline2' (with a single quote)?
The single quotation sign is designed to "turn off" subexpansion.

Shay
http://scriptolog.blogspot.com


Quote:

> "Marco Shaw [MVP]" <marco.shaw@_NO_SPAM_gmail.com> wrote in message
> news:uq78EBPDIHA.2004@xxxxxx
>
Quote:
Quote:

>>>> and it will create a string with a CR/LF sequence in the middle.
>>>> In the Exchange Management Shell, which I thought was essentially
>>>> Powershell, that doesn't work. The backtick character no longer
>>>> acts as an esacpe sequence for special characters and I haven't
>>>> been able to find any mention of this change anywhere.
>>>>
>> This is from the Exchange 2007 shell in my VM:
>>
>> [PS] >$t = "line1`r`nline2"
>> [PS] >$t
>> line1
>> line2
>> You're not seeing the same?
>>
> What I was seeing yesterday was
> [PS] >$t
> line1`r`nline2
> today it is working; same system, same everything, no reboot,... I'll
> have to try to figure out what I did yesterday that confused it
>

My System SpecsSystem Spec
Old 10-12-2007   #8 (permalink)
Bob Butler


 
 

Re: exchange shell escape character

"Shay Levi" <no@xxxxxx> wrote in message
news:8766a94496eb8c9db1aeaf551a6@xxxxxx
Quote:

> Any other PS Snapins included or "Dot Sourced" Scripts in your EMS
> profile?
> Something that can break/override PowerShell defaults???
I had written and tested a powershell script that was working fine. I ran
that exact script from the exchange shell and it failed miserably. Several
things blew up but all were related to the escape sequence. Things like:
$ncmd="this is some text`r`n"
$ncmd+="and this is more`r`n"
resulted in a syntax error that made no sense. A test parsing routine that
had
$lines=$request.Split("`n")
resulted in an array of lines broken on "n" rather than "`n"

The exact same .ps1 file ran fine under powershell and required extensive
reworking under the exchange shell. Today it's running fine under both.
Something got hosed somewhere and if I can duplicate it again I'll try to
track down the problem. I had started and stopped the exchange shell,
logged on and off and rebooted in between tests and it was very consistently
not working. Maybe it just doesn't like Thursdays! <g>


My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Escape character question PowerShell
How can I escape a slash character in item name? PowerShell
How do I escape the wildcard character in a path string? PowerShell
howto? escape the comment character PowerShell
Bug in escape character / variable expansion? 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