首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Windows Defender命令行找不到更新

Windows Defender命令行找不到更新
EN

Server Fault用户
提问于 2018-06-16 09:17:00
回答 1查看 902关注 0票数 0

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

代码语言:javascript
复制
"C:\Program Files\Windows Defender\MpCmdRun.exe" -SignatureUpdate

结果是

代码语言:javascript
复制
Signature update started . . .
Signature update finished. No updates needed

但是Windows显示有3个定义可用,它们可以与Windows客户端一起安装。

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

EN

回答 1

Server Fault用户

发布于 2018-10-24 21:43:23

我现在用Powershell脚本来做这件事。虽然还不完美,但确实有效。

代码语言:javascript
复制
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   
}
票数 0
EN
页面原文内容由Server Fault提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://serverfault.com/questions/916923

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档