Powershell 禁止Outlook弹出窗口允许访问

Powershell 禁止Outlook弹出窗口允许访问,powershell,outlook,Powershell,Outlook,运行以下PowerShell代码时: $Outlook = New-Object -ComObject Outlook.Application $Stores = $Outlook.Session.Stores $Accounts = $Outlook.Session.Accounts $Accounts | Select-Object DisplayName, UserName, SmtpAddress, ExchangeMailboxServerName, ExchangeMailb

运行以下PowerShell代码时:

$Outlook = New-Object -ComObject Outlook.Application   
$Stores = $Outlook.Session.Stores 
$Accounts = $Outlook.Session.Accounts
$Accounts | Select-Object DisplayName, UserName, SmtpAddress, ExchangeMailboxServerName, ExchangeMailboxServerVersion
将弹出一个安全警告:

据了解,这是有办法的。例如,可以
为Outlook创建COM外接程序,而不必使用
Outlook COM对象
。Outlook
自定义
COM加载项的另一个示例发布在StackOverflow上,但用于另一种语言


使用
Globals.ThisAddIn.Application
应该可以做到这一点,不是吗?有人能给我解释一下这是怎么用PowerShell实现的吗?如果我们能够避免出现此弹出窗口,那就太好了,因为它只会让用户感到困惑。

您需要确保计算机上安装了最新的防病毒产品(如果您可以控制客户端环境),或者使用或绕过安全提示。有关更多详细信息,请参阅。

在运行代码之前,以本地管理员身份编辑注册表,找到了一个:

Function Remove-OutlookSecurityPromptHC {
    [CmdLetBinding()]
    Param()

    if (Test-Path -Path 'HKLM:\SOFTWARE\Microsoft\Office\14.0\Outlook') {
        Write-Verbose 'Found MS Outlook 2010'

        if (-not (Test-Path -Path 'HKLM:\SOFTWARE\Microsoft\Office\14.0\Outlook\Security')) {
            New-Item -Path 'HKLM:\SOFTWARE\Microsoft\Office\14.0\Outlook\Security' | Out-Null
        }
        Set-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Office\14.0\Outlook\Security' -Name ObjectModelGuard -Value 2
        Set-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Office\14.0\Outlook\Security' -Name PromptOOMSend -Value 2
        Set-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Office\14.0\Outlook\Security' -Name AdminSecurityMode -Value 3
        Write-Verbose 'Outlook warning suppressed'
    }

    if (Test-Path -Path 'HKLM:\SOFTWARE\Microsoft\Office\12.0\Outlook') {
        Write-Verbose 'Found MS Outlook 2007'

        if (-not (Test-Path -Path 'HKLM:\SOFTWARE\Microsoft\Office\12.0\Outlook\Security')) {
            New-Item -Path 'HKLM:\SOFTWARE\Microsoft\Office\12.0\Outlook\Security' | Out-Null
        }
        Set-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Office\12.0\Outlook\Security' -Name ObjectModelGuard -Value 2
        Set-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Office\12.0\Outlook\Security' -Name PromptOOMSend -Value 2
        Set-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Office\12.0\Outlook\Security' -Name AdminSecurityMode -Value 3
        Write-Verbose 'Outlook warning suppressed'
    }
}

Remove-OutlookSecurityPromptHC -Verbose

运行此代码后,可能需要重新启动/注销才能将其激活。

没有仅Powershell(没有第三方代码)选项来抑制此消息?不幸的是,不是我的朋友,如果你问我的话,有点古怪的设计。