【发布时间】:2022-04-28 00:04:53
【问题描述】:
我需要以编程方式(最好是通过 PowerShell)配置 Outlook 设置选项:
- “发送电子邮件时,按以下顺序检查地址列表:”到“从联系人文件夹开始”。
- “打开通讯录时,先显示此通讯录:”到“Outlook通讯录”。
事实证明,这个问题特别难以捉摸,我已经研究了好几个小时,所以我的综合结果可能看起来有点混乱。
选项#1
如果我没记错的话,以下 PowerShell 命令成功配置了选项:
New-ItemProperty -Path "HKCU:\Software\Microsoft\Office\<Outlook version>\Outlook\Profiles\<mail profile name>\0a0d020000000000c000000000000046\" -Name "000b3d1c" -PropertyType "Binary" -Value 0x00,0x00 -Force;
New-ItemProperty -Path "HKCU:\Software\Microsoft\Office\<Outlook version>\Outlook\Profiles\<mail profile name>\0a0d020000000000c000000000000046\" -Name "00033d1b" -PropertyType "Binary" -Value 0x02,0x00,0x00,0x00 -Force;
选项 #2
将注册表项 HKCU\Software\Microsoft\Office\<Outlook version>\Outlook\Profiles\<mail profile name> 导出到 REG 文件、重新创建邮件配置文件、导入 REG 文件并打开 Outlook 显示选项已根据需要设置。所以,它可以通过注册表来完成。
进程监视器,配置为使用过滤器 Process Name is OUTLOOK.EXE Include 和 Operation is RegSetValue Include 监视注册表操作,总是输出略有不同的结果,但一致的结果是:
15:48:56.9983649 OUTLOOK.EXE 531284 RegSetValue HKCU\Software\Microsoft\Office\15.0\Outlook\Profiles\Student\9207f3e0a3b11019908b08002b2a56c2\01023d06 成功类型:REG_BINARY,长度:4000000000000000000000 0A 18 C7 1A 10 E8 85 0B 65
15:48:56.9991115 OUTLOOK.EXE 531284 RegSetValue HKCU\Software\Microsoft\Office\15.0\Outlook\Profiles\Student\0a0d020000000000c000000000000046\000b3d1c 成功类型:REG_BINARY,长度:2,数据:00>
15:48:56.9996963 OUTLOOK.EXE 531284 RegSetValue HKCU\Software\Microsoft\Office\15.0\Outlook\Profiles\Student\0a0d020000000000c000000000000046\00033d1b 成功类型:REG_BINARY,长度:4,数据:02 >
15:48:57.0052360 OUTLOOK.EXE 531284 RegSetValue HKCU\Software\Microsoft\Office\15.0\Outlook\Profiles\Student\4ae4e14443f96d4982c25a0b9340e560\000b048b 成功类型:REG_BINARY,长度:2,数据:01 0
15:49:03.0985853 OUTLOOK.EXE 531284 RegSetValue HKCU\Software\Microsoft\Office\15.0\Outlook\Profiles\Student\0a0d020000000000c000000000000046\1102039b 成功类型:REG_BINARY,长度:010008,数据:0D 00 00 00 00 00 14 00 00 00
15:49:03.0990695 OUTLOOK.EXE 531284 RegSetValue HKCU\Software\Microsoft\Office\15.0\Outlook\Profiles\Student\0a0d020000000000c000000000000046\000b0415 成功类型:REG_BINARY,长度:2,数据:00>
但是,以下 PowerShell 命令未成功配置选项:
New-ItemProperty -Path "HKCU:\Software\Microsoft\Office\<Outlook version>\Outlook\Profiles\<mail profile name>\0a0d020000000000c000000000000046\" -Name "000b046b" -PropertyType "Binary" -Value 0x01,0x00 -Force;
New-ItemProperty -Path "HKCU:\Software\Microsoft\Office\<Outlook version>\Outlook\Profiles\<mail profile name>\9207f3e0a3b11019908b08002b2a56c2\" -Name "01023d06" -PropertyType "Binary" -Value 0x00,0x00,0x00,0x00,0xFE,0x42,0xAA,0x0A,0x18,0xC7,0x1A,0x10,0xE8,0x85,0x0B,0x65 -Force;
New-ItemProperty -Path "HKCU:\Software\Microsoft\Office\<Outlook version>\Outlook\Profiles\<mail profile name>\0a0d020000000000c000000000000046\" -Name "000b3d1c" -PropertyType "Binary" -Value 0x00,0x00 -Force;
New-ItemProperty -Path "HKCU:\Software\Microsoft\Office\<Outlook version>\Outlook\Profiles\<mail profile name>\0a0d020000000000c000000000000046\" -Name "00033d1b" -PropertyType "Binary" -Value 0x02,0x00,0x00,0x00 -Force;
New-ItemProperty -Path "HKCU:\Software\Microsoft\Office\<Outlook version>\Outlook\Profiles\<mail profile name>\0a0d020000000000c000000000000046\" -Name "000b0340" -PropertyType "Binary" -Value 0x01,0x00 -Force;
New-ItemProperty -Path "HKCU:\Software\Microsoft\Office\<Outlook version>\Outlook\Profiles\<mail profile name>\9207f3e0a3b11019908b08002b2a56c2\" -Name "11023d05" -PropertyType "Binary" -Value 0x02,0x00,0x00,0x00,0x1E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x24,0x00,0x00,0x00 -Force;
New-ItemProperty -Path "HKCU:\Software\Microsoft\Office\<Outlook version>\Outlook\Profiles\<mail profile name>\b9e1c8a47102f24688ede3f23cbc5224\" -Name "0102663b" -PropertyType "Binary" -Value 0x0F,0x00,0x01,0x00,0x8C,0x01,0x21,0x00 -Force;
New-ItemProperty -Path "HKCU:\Software\Microsoft\Office\<Outlook version>\Outlook\Profiles\<mail profile name>\0a0d020000000000c000000000000046\" -Name "1102039b" -PropertyType "Binary" -Value 0x01,0x00,0x00,0x00,0x1D,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x14,0x00,0x00,0x00 -Force;
New-ItemProperty -Path "HKCU:\Software\Microsoft\Office\<Outlook version>\Outlook\Profiles\<mail profile name>\0a0d020000000000c000000000000046\" -Name "000b0415" -PropertyType "Binary" -Value 0x00,0x00 -Force;
Set Outlook's 'show this address list first' option 建议这可以通过使用 ComObjects 来完成,但测试表明 Outlook 检测到该活动为恶意活动并提示需要手动干预的安全警告,这显然是有问题的,因为它不是 100%程序化。
https://social.technet.microsoft.com/Forums/exchange/en-US/85a392d4-fc85-43c5-9c02-c07ec86e2ade/default-address-list?forum=exchangesvrclientslegacy 和 https://social.technet.microsoft.com/Forums/office/en-US/6bb9b40f-b794-41ce-93b4-711e77c53607/gal-default-adress-book-gpo 表示注册表键 *\<mail profile name>\9207f3e0a3b11019908b08002b2a56c2 -> 值 01023d06 是由 Process Monitor 检测到的,但如上所述,它在我的测试中不起作用。
【问题讨论】:
标签: powershell outlook registry programmatically-created