我是 powershell 脚本的新手。windowsdefender
从命令行扫描文件。我做错了什么?
function scan { Start-Process "C:\program files\windows defender\mpcmdrun.exe" -Scan -ScanType 3 -File $args[0] }
C:\Program Files\Windows Defender>MpCmdRun -scan -scantype 3 -file *.dll 扫描开始... CmdTool:失败,hr = 0x80508023。检查 C:\Users\exp\AppData\Local\Temp\MpCmdRun.log 以获得更多信息 MpCmdRun: 命令行: "C:\program files\windows defender\MpCmdRun.exe" -scan -scantype 3 -file *.dll Start时间:马。十月。06 2020 23:36:36
MpEnsureProcessMitigationPolicy:hr = 0x1 正在启动 RunCommandScan。信息:未设置 ScheduleJob。跳过签名更新。扫描路径为文件:*.dll。开始:MpScan(MP_FEATURE_SUPPORTED, dwOptions=16385, path *.dll, DisableRemediation = 0, BootSectorScan = 0, Timeout in days = 1) MpScan() 已启动 警告:MpScan() 遇到错误。hr = 0x80508023 MpScan() 已完成 ERROR: MpScan(dwOptions=16385) Completion Failed 80508023 MpCmdRun: End Time: ma. 十月。06 2020 23:36:36
要修复您的功能,您需要通过 -ArgumentList 传递 cmd 参数
已经有一个 PowerShell Cmdlet 可以执行此操作: