powershell - 如何使用 Powershell 向本地 Outlook 联系人添加证书?
问题描述
我正在尝试整理 Outlook 中的当前联系人以替换加密证书。但不清楚如何准备对象?
# В var $contactList collect contacts from Outlook
foreach ( $name in $contactList ) {
$PR_x509_Certificate = ('http://schemas.microsoft.com/mapi/proptag/0x3A701102');
# Create new contact
$NewContact = $Outlook.CreateItem('olContactItem');
# Get email, name, fullname from old contact
$NewContact.Email1Address = $name.Email1Address;
$NewContact.FullName = $name.FullName;
$NewContact.FirstName = $name.FirstName;
# Import certificate from из .cer file
$NewCertUser = New-Object system.security.cryptography.x509certificates.x509certificate2;
$NewCertUser.Import($PathToCerFile);
# Try add sertificate, but no success :(
$result = $NewCertUser.RawData;
$o = New-Object BuildProperty($result);
$NewContact.PropertyAccessor.SetProperty($PR_x509_Certificate, $o);
# Save new contact
$NewContact.Save();
# Delete old
$name.Delete();
}
我正在尝试更新这个: