Powershell 更改Outlook 2013中的编程访问选项

Powershell 更改Outlook 2013中的编程访问选项,powershell,outlook,Powershell,Outlook,我使用Outlook 2013和Powershell脚本 如何使用Powershell以编程方式更改Outlook 2003中的编程访问选项?这适用于本地或远程主机(使用Office 2016在Windows 10上测试): 嗯,我想你必须改变一些注册表值,正如你在添加的链接中所解释的那样?那么你是想绕过安全提示吗?有关选项列表,请参见。 #config $computerName = $env:COMPUTERNAME $hive = "LocalMachine" #replace 16.0

我使用Outlook 2013和Powershell脚本


如何使用Powershell以编程方式更改Outlook 2003中的编程访问选项?

这适用于本地或远程主机(使用Office 2016在Windows 10上测试):


嗯,我想你必须改变一些注册表值,正如你在添加的链接中所解释的那样?那么你是想绕过安全提示吗?有关选项列表,请参见。
#config
$computerName = $env:COMPUTERNAME
$hive = "LocalMachine"
#replace 16.0 with 15.0 for Outlook 2013, 14.0 for Outlook 2010 and 12.0 for Outlook 2007
$regPath = "SOFTWARE\Microsoft\Office\16.0\Outlook"

#if remote computer is reachable
if(Test-Connection $computerName -Quiet -Count 2 -ErrorAction 0) {
    try {
        #open remote registry
        $base = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey([Microsoft.Win32.RegistryHive]::$hive, $ComputerName)

        #open desired key with edit permission
        $key = $base.OpenSubKey($regPath, $true)

        #if Security subkey does not exist
        if($key.GetSubKeyNames() -notcontains "Security") {

            #create Security subkey
            $key.CreateSubKey("Security") | Out-Null
        }

        #open Security subkey
        $subkey = $key.OpenSubKey("Security", $true)

        #set or create ObjectModelGuard value
        $subkey.SetValue("ObjectModelGuard", 2, "Dword")

        #close subkey, key and registry connection
        $subkey.Close()
        $key.Close()
        $base.Close()
    } catch {
        Throw "Remote registry is not accessible (check `$hive and `$regPath)."
    }
} else {
    Throw "Remote computer is not reachable."
}