|
Guy recommends :
Find out which of your VMs are a waste of space and which VMs need more resources.
|
Windows PowerShell QuotesIntroduction to Windows PowerShell QuotesDid you ever use a traditional single-bladed screwdriver on a square 'Philips' head? Sometimes you get away with it, but sooner or later you will literally "screw up" - well it's the same with PowerShell's quotes. Topics for PowerShell Quotes
♣ Introduction to the right sort of PowerShell quotation markIn Windows PowerShell, there are two types of quotes 'single speech marks' and "double speech marks"; each has a particular meaning and significance. The first point is that merely because you use a string, PowerShell does not require any sort of quote. That said, there are times when you will need not only quotes, but also the right sort of quote, for example: # PowerShell quotes needed The above command draws an error message, something about a parameter called and. Fortunately, quotes will solve the problem thus: set-location "c:\ documents and settings" Either single or double quotes work in this instance, and you may deduce that they will always be interchangeable - wrong. Take the time to understand the different role for 'single quotes' and "double quotes". Example 1 PowerShell 'Single Quote'Call me paranoid, but when I say 'Single Quote', I am talking about the key sandwiched between the semi-colon and the hash # key. This key is also known as the Apostrophe and corresponds to ASCII 039 in decimal. # PowerShell Single Quotes We have a problem, the above command does not expand the variable $Days into the number 7. What happens instead is we get the literal: There are $Days in a week. Let us see what happens with double quotes in example 2.
Guy Recommends: SolarWinds' Free Bulk Import Tool
|
||||
Custom Search
|
Guy Recommends: WMI Monitor and It's Free!
|
|
Author: Guy Thomas Copyright © 1999-2012 Computer Performance LTD All rights reserved. Please report a broken link, or an error to: | |