首页 > 解决方案 > 如何使用 powershell 将成员添加到分发列表?

问题描述

我尝试使用 powershell 将用户添加到分发列表,但我没有找到正确的命令。

$outlook = new-object -com Outlook.Application
$list= $outlook.Session.GetGlobalAddressList().AddressEntries.Item("TEST Liste")
$idnew = $outlook.Session.GetGlobalAddressList().AddressEntries.Item("Max Mustermann")

我得到了帮助

$list.Members.Add(
Add
                                                                                                                                                                         
AddressEntry Add (string, Variant, Variant)   

并发现它应该是(字符串类型、对象名称、对象地址)(https://docs.microsoft.com/en-us/dotnet/api/microsoft.office.interop.outlook.addressentries.add?view= Outlook-pia#Microsoft_Office_Interop_Outlook_AddressEntries_Add_System_String_System_Object_System_Object_

但我有一个错误

$list.Members.Add($idnew.Type, $idnew.Name, $idnew.Address)
Die Textmarke ist ungültig.
In Zeile:1 Zeichen:1
+ $list.Members.Add($idnew.Type, $idnew.Name, $idnew.Address)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : OperationStopped: (:) [], COMException
    + FullyQualifiedErrorId : System.Runtime.InteropServices.COMException

那么,有人可以帮助我吗?这是错误的方式吗?

标签: powershelloutlook-restapi

解决方案


推荐阅读