How do quotes/strings work in Powershell?
Posted
by
Casey
on Server Fault
See other posts from Server Fault
or by Casey
Published on 2011-01-07T17:43:17Z
Indexed on
2011/01/07
17:55 UTC
Read the original article
Hit count: 206
I'm have a command line that works in the regular old Windows Command Shell, but somehow gets misinterpreted in Powershell (I'm fairly new to Powershell).
sqlcmd -S .\SQLEXPRESS -i "f:\SQLBackups\ExpressMaint.sql" -v DB="ksuite" -v OPTYPE="DB" -v BACKUPFOLDER="f:\SQLBackups" -v REPORTFOLDER="f:\SQLBackups\Reports" -v DBRETAINUNIT="days" -v DBRETAINVAL="7"
Powershell seems to be stripping the drive letters out of the arguments that require paths. For example, I get the following when I attempt to run the above command in Powershell:
Sqlcmd: ':\SQLBackups': Invalid argument. Enter '-?' for help.
Well sure it's invalid without the drive letter. I have tried variations on double quoting it, escaping it, etc. but can't get it to work. What am I missing that Powershell does differently?
© Server Fault or respective owner