从 PowerShell 搜索 Lotus Notes 数据库
Search a Lotus Notes database from PowerShell
我正在尝试从 PowerShell 搜索 Lotus Notes 数据库并获得 "Type Mismatch. (Exception from HResult: 0x80020005 (DISP_E_TYPEMISMATCH)" At line 1: char:1
。
设置代码:
$notesSession = New-Object -ComObject Lotus.NotesSession
$notesSession.Initialize()
$notesDb = $notesSession.GetDatabase(..., ...)
我在尝试时遇到错误...
$results = $notesDb.Search("text", $null, 0)
$results = $notesDb.Search("text", $(Get-Date), 0)
$results = $notesDb.Search("text", $([System.DateTime]::Now), 0)
有人能找出错误吗?我认为错误与日期参数有关,因此我多次尝试。
错误似乎来自 .Search
wants a notesDateTime
object for that parameter。所以理论上你只需要创建一个 notesdatetime
对象并将其传递给搜索方法。
$searchDate = $notesSession.CreateDateTime(get-date -f "yyyy-MM-dd")
我无法对此进行测试,也不确定如何通过将 $null 传递给 CreateDateTime 方法来获取 null return。
Unsure if this is the correct reference for the COM implementation 但来自参数部分
The date and time you want the object to represent. If you use an empty string (""), the date is set to a wildcard date. The Notes date-time expressions "Today," "Tomorrow" and "Yesterday" are supported.
我正在尝试从 PowerShell 搜索 Lotus Notes 数据库并获得 "Type Mismatch. (Exception from HResult: 0x80020005 (DISP_E_TYPEMISMATCH)" At line 1: char:1
。
设置代码:
$notesSession = New-Object -ComObject Lotus.NotesSession
$notesSession.Initialize()
$notesDb = $notesSession.GetDatabase(..., ...)
我在尝试时遇到错误...
$results = $notesDb.Search("text", $null, 0)
$results = $notesDb.Search("text", $(Get-Date), 0)
$results = $notesDb.Search("text", $([System.DateTime]::Now), 0)
有人能找出错误吗?我认为错误与日期参数有关,因此我多次尝试。
错误似乎来自 .Search
wants a notesDateTime
object for that parameter。所以理论上你只需要创建一个 notesdatetime
对象并将其传递给搜索方法。
$searchDate = $notesSession.CreateDateTime(get-date -f "yyyy-MM-dd")
我无法对此进行测试,也不确定如何通过将 $null 传递给 CreateDateTime 方法来获取 null return。
Unsure if this is the correct reference for the COM implementation 但来自参数部分
The date and time you want the object to represent. If you use an empty string (""), the date is set to a wildcard date. The Notes date-time expressions "Today," "Tomorrow" and "Yesterday" are supported.