سؤال

The following PowerShell script:

$srch = '-v\s*(.*?)\s*=\s*%1'
$repl = "-v `'`$1'` = %1"
(Get-Content batchfile.bat) -replace $srch, $repl | Set-Content rave.bat

produces these results from a Windows 8.1 machine:

sqlcmd -S rave -v 'test me' = %1 -i rave_params.sql -o alert.txt

The same script produces these results from a Windows 2012 server:

sqlcmd -S rave -v test me = %1 -i rave_params.sql -o alert.txt

The script is supposed to produce results leaving the single quotes around the text. It works fine on the Windows 8.1 machine yet does not on Windows Server 2012. Any ideas what I can do to produce the same results on Windows Server 2012?

هل كانت مفيدة؟

المحلول

Without sample input it's hard to test, but does this give you any better results?

$srch = '-v\s*(.*?)\s*=\s*%1'
$repl = @'
-v '$1' = %1
'@
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top