I have a bat file and I need to use it to call a powershell script.
I need to pass this powershell script a jdbc connect string which has lots of brackets and @'s. I have made a simple example which demos my problem.
my test.bat is as follows:
@PowerShell.exe -Command "C:\off_desk\ci\test\test.ps1 %1 %2 %3 %4 %5 %6 %7 %8 %9"
I use this with test.ps1 which is as follows:
Param(
[string]$one
)
Write-Host "Got $one"
When I run:
test jdbc:oracle:thin:@(DESCRIPTION=(enable=broken)(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=cc-rjmetcal)(PORT=1521)))(CONNECT_DATA=(service_name=CITESTDB_001))))
I get an error:
Missing closing ')' in expression.
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : MissingEndParenthesisInExpression
I have tried running with quotes:
test "jdbc:oracle:thin:@(DESCRIPTION=(enable=broken)(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=cc-rjmetcal)(PORT=1521)))(CONNECT_DATA=(service_name=CITESTDB_001))))"
but this also errors.
I have tried many things I have found on the internet. Surrounding it with @and @" and various other things. None worked. I am limited by what a bat can do so I can't search the string for all the escape chars and prefix them with.
Does anyone have a solution?
%*be simpler?