我使用Outlook 2013和Powershell脚本。
如何使用 Powershell Outlook 2003中的programmatic-access-options更改以编程方式?
答案 0 :(得分:0)
适用于本地或远程主机(在Windows 10上使用Office 2016进行测试):
#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."
}