使用 Powershell 查询 Outlook 插件

Query Outlook Addins with Powershell

我必须查询我的 Outlook 加载项并检查是否安装了两个特定的加载项。

这是我的:

$searchScopes = "HKCU:\SOFTWARE\Microsoft\Office\Outlook\Addins","HKLM:\SOFTWARE\Wow6432Node\Microsoft\Office\Outlook\Addins"
$searchScopes | % {Get-ChildItem -Path $_ | % {Get-ItemProperty -Path $_.PSPath} | Select-Object @{n="Name";e={Split-Path $_.PSPath -leaf}},FriendlyName,Description} | Sort-Object -Unique -Property name

这显示了所有已安装的加载项。现在我不知道如何过滤结果以获得真或假。

点赞

If List contains 'addin1' then 'addin1' installed = true

使用您的代码,将第二行添加到变量中

$searchScopes = "HKCU:\SOFTWARE\Microsoft\Office\Outlook\Addins","HKLM:\SOFTWARE\Wow6432Node\Microsoft\Office\Outlook\Addins"
$Results = $searchScopes | % {Get-ChildItem -Path $_ | % {Get-ItemProperty -Path $_.PSPath} | Select-Object @{n="Name";e={Split-Path $_.PSPath -leaf}},FriendlyName,Description} | Sort-Object -Unique -Property name

接着查询结果:

$Results.Name -contains 'TeamViewerMeetingAddIn.AddIn'

$Results.FriendlyName -match 'Google Apps'

要筛选:

$Results | ? {$_.Name -contains 'TeamViewerMeetingAddIn.AddIn'}

你有插件列表来检查它们是否已安装吗?发现安装或未安装后,您想做什么?

您可以使用 -in 运算符,它根据列表检查值,如果值在列表中则为真。这段代码所做的只是打印到主机;需要更改循环中的逻辑以满足您的要求。

$searchScopes = "HKCU:\SOFTWARE\Microsoft\Office\Outlook\Addins","HKLM:\SOFTWARE\Wow6432Node\Microsoft\Office\Outlook\Addins"
$names = $searchScopes | % {Get-ChildItem -Path $_ | % {Get-ItemProperty -Path $_.PSPath} | Select-Object @{n="Name";e={Split-Path $_.PSPath -leaf}},FriendlyName,Description} | Sort-Object -Unique -Property name

if("addin1" -in $names){
    Write-Host "addin1 is installed."
}