1
私は、スイッチパラメータを含むいくつかのパラメータを持つPowerShellスクリプトを持っています。コマンドシェルプロンプトからスイッチパラメータを渡すことができません
のPowerShell内で実行される以下のコマンドは期待通りに動作します:
\\localhost\Test\Code\DataPullResults.ps1 -TestName 'Test survey' -QUser '[email protected]' -SqlServerInstanceName localhost -SqlDatabaseName MyDatabase -Load:$True -ErrorAction Continue;
しかし、私は、コマンドプロンプトから同じコマンドを実行したとき、私はエラーを取得する:
以下\\localhost\Test\Code\DataPullResults.ps1 : Cannot process
argument transformation on parameter 'FullLoad'. Cannot convert value
"System.String" to type "System.Management.Automation.SwitchParameter".
Boolean parameters accept only Boolean values and numbers, such as $True,
$False, 1 or 0.
はコマンドです私はコマンドプロンプトから実行していました。
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe powershell.exe -ExecutionPolicy ByPass -File \\localhost\Test\Code\DataPullResults.ps1 -TestName 'Test survey' -QUser '[email protected]' -SqlServerInstanceName localhost -SqlDatabaseName MyDatabase -Load:$True -ErrorAction Continue;
ここでLoad
はスイッチパラメータです。
はい私はPosershell.exeを2回使用していますが、これは別のスクリプトでうまくいきます。 – Roshan
同じエラーが発生しましたが、-Fileの代わりに-Commandを試しました。その他のヘルプ – Roshan
'$ true'値を省略するとどうですか? –