PowerShell远程注册表

时间:2014-09-23 22:28:13

标签: registry remote-access powershell-v3.0

我有以下代码,它检查本地注册表中的所有程序显示名列表,并给出和' if'如果安装了Symantec,则发出警报声明。

$List = Get-ItemProperty HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*

if ($List.displayname -Match "Symantec")
{ Write-Host "Symantec is installed." -ForegroundColor Green }
else
{ Write-Host "Symantec is not installed." -ForegroundColor Red }

有人可以告诉我如何使用远程注册表获取此代码以检查远程服务器吗?

1 个答案:

答案 0 :(得分:0)

您可以将脚本包装到invoke-command中:

icm -ComputerName computer1 -ScriptBlock { 
    $List = Get-ItemProperty HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*

    if ($List.displayname -Match "Symantec")
    { Write-Host "Symantec is installed." -ForegroundColor Green }
    else
    { Write-Host "Symantec is not installed." -ForegroundColor Red }
}