タスクスケジューラでPowerShellスクリプトを実行する際に問題があります。 PowerShell ISEでスクリプトを作成しても問題ありません。PowerShellとPowerShell ISE
しかし、PowerShellで実行すると、いくつかの間違いが報告されます。
これはなぜ起こり得るのですか?
私は
powershell_ise.exe -File D:\script.ps1
または
powershell.exe -File D:\script.ps1
で単一行ファイルを作成しようとしました。しかし、それのどちらも動作します。 ポリシーを確認しましたが、制限はありません。
私はPowerShellのISEに
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -NonInteractive -Command d:\Script.ps1
を実行しようとしている、それが正常に動作します。私はPowerShellでそれを実行すると
は、それがエラーを示しています。-formatため
The term '▬' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:1
$datetime = Get-Date -f yyyMMdd
$strFileName = "c:\test\BS_" + $datetime + ".txt"
if (Test-Path $strFileName) {
exit
} else {
exit
}
...
「いくつかの間違いがあります」というエラーメッセージが含まれているのでしょうか。それらは問題に関連していないと思います。何故ですか? – vonPryz
.ps1ファイルはダッシュ '--'で始まりますか? – vonPryz
いいえ、BS_test.ps1 – HeadOverFeet