I am trying to search a Lotus Notes database from PowerShell and getting a "Type Mismatch. (Exception from HResult: 0x80020005 (DISP_E_TYPEMISMATCH)" At line 1: char:1
.
Set-up code:
$notesSession = New-Object -ComObject Lotus.NotesSession
$notesSession.Initialize()
$notesDb = $notesSession.GetDatabase(..., ...)
I get the errors when trying...
$results = $notesDb.Search("text", $null, 0)
$results = $notesDb.Search("text", $(Get-Date), 0)
$results = $notesDb.Search("text", $([System.DateTime]::Now), 0)
Can anybody spot the mistake? I think the error is to do with the date argument, hence my multiple attempts.
The error seems to be coming from the fact that .Search
wants a notesDateTime
object for that parameter. So in theory you just need to create a notesdatetime
object and pass that to the search method.
$searchDate = $notesSession.CreateDateTime(get-date -f "yyyy-MM-dd")
I am not in a position to test this nor am I sure how to get a null return from this short of passing $null to the CreateDateTime method.
Unsure if this is the correct reference for the COM implementation but from the parameter section
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.
User contributions licensed under CC BY-SA 3.0