次の1行のコマンドを複数の行に変換しようとすると、何かが見当たりません。私が見つけ、検索、そして私が何をしないのですPowershell -Command over multiple linePowerShellを実行中のcmdの引用符で囲んだりエスケープしたり、cmdを実行しています
後、この変更をモデル化しようとしましたか?私はそれを簡単にテストしようとしました。最初の2行をシステムに適したものに変更してください。
===出力は、私はそれがまだ行ごとに複数のコマンドですので、例のみ働くと信じ
C:>call emailtest.bat
12:17:24.75 C:\Users\me\t
C:>powershell -Command "& send-mailmessage -to "[email protected]" -from '[email protected]' -subject 'test file transfer' -SmtpServer 'imr2.nowhere.org' -BodyAsHTML 'The file is <a href="C:\Windows\win.ini">here</a> for you.'
12:17:27.28 C:\Users\me\t
C:>powershell -noprofile -Command "&{" send-mailmessage -to "[email protected]" -from '[email protected]' -subject 'test file transfer' -SmtpServer 'imr2.nowhere.org' -BodyAsHTML 'The file is href="C:\Windows\win.ini""}" 0</a 1>for
The system cannot find the file specified.
物事はあなたがPowerShellはcmd.exeシェルスクリプト(バッチファイル)でコマンドをラップしようとしているの代わりに、直接PowerShellを使用している場合、簡単かつ単純になります。 –