Powershell : A Quick-Start Beginner's Guide by Andy Hayes

Powershell : A Quick-Start Beginner's Guide by Andy Hayes

Author:Andy Hayes [Hayes, Andy]
Language: eng
Format: azw3
Published: 2017-01-16T16:00:00+00:00


Write-Output “String ‘in’ quotes.” Write-Output ‘String “in”quotes.’

If you refer again to Figure 1, you’ll see that inside quotes in both cases are carried to the output.

This isn’t the case when you use the same type of quotes throughout the string:

Write-Output “String “in”quotes.” Write-Output ‘String ‘in’ quotes.’

As Figure 1 shows, the results are quite different. In both cases, the quotes are not displayed and a new line is added. This is because PowerShell interprets the one string as multiple strings and conse- quently adds a line break. For example, PowerShell interprets String as the first string (so it adds a line break after that string), then interprets the rest as a different string. You can use double quotes within double quotes, but you must escape the inside quotes, which I’ll describe how to do later.

Whenever you work with quotes, be careful not to mix up the type of quotes or forget to include one. Otherwise, you might get stuck in a loop that continues to prompt you for an entry, but nothing you enter gets you out of the loop. If you run into that situation, press Ctrl+C to return to the command prompt.



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.