问题描述
我正在尝试在Outlook中检索有关全局地址列表的信息。 它可以在Powershell 5.1中工作,但不能在7.0.3中工作。
代码为:
$Outlook = NEW-Object -comobject outlook.application
$Outlook.GetNamespace("MAPI").AddressLists("Global Address List")
PS 5.1中的输出:
Application : Microsoft.Office.Interop.outlook.applicationClass
Class : 7
Session : Microsoft.Office.Interop.Outlook.NameSpaceClass
Parent : System.__ComObject
AddressEntries : System.__ComObject
ID : 00000000E3FDA12B9AF86342819F3DEFE5D82FE001000000000100002F00
Index : 2
IsReadOnly : True
Name : Global Address List
AddressListType : 0
Resolutionorder : 1
IsInitialAddressList : True
PropertyAccessor : System.__ComObject
PS 7.0.3中的输出:
Method invocation Failed because [System.__ComObject] does not contain a method named 'AddressLists'.
您是否知道为什么在新的Powershell版本中无法使用?
解决方法
我可以复制该问题。这对您有用吗?它给出相等的结果$Outlook.GetNamespace("MAPI").AddressLists | Where {$_.name -eq 'Global Address List'}