简体   繁体   中英

Running PowerShell script with arguments

I've been trying to run a PowerShell script with CMD without success.

The script i'm running:

C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -command 'C:\Program Files\Tivoli\TSM\start-tdpsql-instance.ps1' -dpsqloptfile h:\tsm\dsm.opt -dpsqlcfgfile h:\tsm\tdpsql.cfg

But unfortunately, i get an error message:

You must provide a value expression on the right-hand side of the '-' operator.
At line:1 char:58
+ 'C:\Program Files\Tivoli\TSM\start-tdpsql-instance.ps1' - <<<< dpsqloptfile h
:\tsm\dsm.opt -dpsqlcfgfile h:\tsm\tdpsql.cfg
+ CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordEx
ception
+ FullyQualifiedErrorId : ExpectedValueExpression

Do you have any ideas why it isn't processing my arguments?

I solved it! =]

C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -Command "& 'C:\Program Files\Tivoli\TSM\start-tdpsql-instance.ps1' -dpsqloptfile 'h:\tsm\dsm.opt' -dpsqlcfgfile 'h:\tsm\tdpsql.cfg'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM