Windows Defender 命令行未找到更新

Windows Defender 命令行未找到更新

我尝试使用命令行实用程序更新 Windows Defender。

"C:\Program Files\Windows Defender\MpCmdRun.exe" -SignatureUpdate

结果是

Signature update started . . .
Signature update finished. No updates needed

但是 Windows Update 显示有 3 个定义可用,并且可以使用 Windows Update 客户端进行安装。

关于如何使用命令行客户端更新 Defender,有什么提示吗?

在此处输入图片描述

答案1

我现在用 Powershell 脚本来做这件事。它还不完美,但可以工作。

Set-StrictMode -Version Latest
$ErrorActionPreference = 'Inquire'

$updateSession = New-Object -ComObject 'Microsoft.Update.Session'
$updateSession.ClientApplicationID = 'Defender Updates installer'

$updateSearcher = $updateSession.CreateUpdateSearcher()

'Searching for updates...'

$searchResults = $updateSearcher.Search("IsInstalled=0 and Type='Software' and IsHidden=0")

if ( $searchResults.Updates.Count -eq 0 )
{
    'There are no applicable updates.'
    return
}

$updatesToDownload = New-Object -ComObject 'Microsoft.Update.UpdateColl'

for ( $i=0; $i -le $searchResults.Updates.Count - 1; $i++ )
{
    $update = $searchResults.Updates.Item($i)
    if ( $update.Title -like '*defender*' )
    {
        $update.AcceptEula()
        $updatesToDownload.Add( $update )
    }
}

if ( $updatesToDownload.Count -eq 0 )
{
    'All applicable updates were skipped.'
    return
}

'Downloading updates...'

$downloader = $updateSession.CreateUpdateDownloader() 
$downloader.Updates = $updatesToDownload
$downloader.Download()

$updatesToInstall = New-Object -ComObject 'Microsoft.Update.UpdateColl'

'Successfully downloaded updates:'

for ( $i=0; $i -le $searchResults.Updates.Count - 1; $i++ )
{
    $update = $searchResults.Updates.Item($i)
    if ( $update.IsDownloaded -eq $true )
    {
        $updatesToInstall.Add( $update )
    }
}

if ( $updatesToInstall.Count -eq 0 )
{
    'No updates were successfully downloaded.'
    return
}

'Installing updates...'
$installer = $updateSession.CreateUpdateInstaller()
$installer.Updates = $updatesToInstall
$installationResult = $installer.Install()

# Output results of install
'Installation Result: ' + $installationResult.ResultCode 
'Reboot Required: ' + $installationResult.RebootRequired

'Listing of updates installed and individual installation results:'

for ( $i=0; $i -le $updatesToInstall.Count - 1; $i++ )
{
    '> ' + $updatesToInstall.Item($i).Title + ': ' + $installationResult.GetUpdateResult($i).ResultCode   
}

相关内容