why is this incorrect?

PS C:\WINDOWS\system32> Get-Service -ServiceName 'bits
>> ’

Get-Service : Cannot find any service with service name 'bits
'.
At line:1 char:1

  • Get-Service -ServiceName 'bits
  • CategoryInfo : ObjectNotFound: (bits
    :String) [Get-Service], ServiceCommandException
  • FullyQualifiedErrorId : NoServiceFoundForGivenName,Microsoft.PowerShell.Commands.GetServiceCommand

any help please in letting me understand why the powershell extended mode doesnt treat the ’ closing in the next line?

It looks like PowerShell is accepting the closing ', but it is also including the return character in the -ServiceName string. Because you are using single quotes, it is taking all of your input literally, so it is searching for a service name that looks like "bits
"
or

bits[return]

[quote quote=181749]It looks like PowerShell is accepting the closing ', but it is also including the return character in the -ServiceName string. Because you are using single quotes, it is taking all of your input literally, so it is searching for a service name that looks like "bits

"

or

<textarea class="ace_text-input" style="opacity: 0; height: 18px; width: 6.59775px; left: 123.173px; top: 0px;" spellcheck="false" wrap="off"></textarea>
1
bits[return]
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
[/quote] Thats correct, but double quotes doesnt work either. It is taking the carriage return value as well along with the closing quotes. Is this extensible shell designed to work only for strings and not for running command let syntax as above?

I think this will solve your problem: PowerTip: Line Continuation in PowerShell - Scripting Blog

*Edit: Actually I think that won’t work. It seems that you can split a command across multiple lines, but you can’t split strings across multiple lines without including the return character between lines: powershell - How to enter a multi-line command - Stack Overflow