我已经尝试过每个教程,但是在设置任务时不会运行。Powershell不从计划任务运行
有人能告诉我如何获得计划的任务在Windows 10上运行PowerShell脚本?
编辑:
一些额外的信息:
我试图运行一个脚本,删除超过10天以上的文件。在这里得到一些帮助。
How can I delete files with PowerShell without confirmation?
$Days = "10"
#----- define folder where files are located ----#
$TargetFolder = "D:\Shares\Downloads\TV\AutoDL"
#----- define LastWriteTime parameter based on $Days ---#
$LastWrite = (Get-Date).AddDays(-$Days)
#----- get files based on lastwrite filter and specified folder ---#
$Files = Get-Childitem $TargetFolder -Recurse -file | Where LastWriteTime -le "$LastWrite"
if ($Files -eq $null)
{
Write-Host "No more files to delete!" -foregroundcolor "Green"
}
else
{
$Files | %{
write-host "Deleting File $_" -ForegroundColor "DarkRed"
Remove-Item $_.FullName -Force | out-null
}
}
在计划任务我有这些设置:我曾尝试 “的PowerShell”, “powershell.exe” 和“C:
最高privliges 程序/脚本运行\ Windows \ System32 \ WindowsPowerShell \ v1.0 \ powershell.exe“
添加参数:我试过”。\ nameofscript.ps1“, - 文件”C:\ Script \ nameofscrips.ps1“, - 命令和其他我发现的建议。
开始在:C:\脚本
我试过设置在这些教程:
请提供你的脚本是做一些更多的信息,以及如何计划任务已配置代码和代码使我们能够提供帮助。说你试过的教程意味着人们可以消除那些对你无用的东西。 – gms0ulman