2017-02-20 85 views
1

我试图从PowerShell搜索Lotus Notes数据库并获取"Type Mismatch. (Exception from HResult: 0x80020005 (DISP_E_TYPEMISMATCH)" At line 1: char:1从PowerShell搜索Lotus Notes数据库

设置代码:

$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) 

任何人能发现错误了吗?我认为这个错误与日期参数有关,因此我尝试了多次。

回答

2

该错误似乎来自.Search wants a notesDateTime object for that parameter这一事实。所以理论上你只需要创建一个notesdatetime对象并将其传递给搜索方法。

$searchDate = $notesSession.CreateDateTime(get-date -f "yyyy-MM-dd") 

我不是在一个位置,以检验这个我也不是知道怎么去从这个短传$空的CreateDateTime方法的返回null。

Unsure if this is the correct reference for the COM implementation但是从参数部分

你想要的对象来表示的日期和时间。如果使用空字符串(“”),则日期设置为通配符日期。 Notes支持日期 - 时间表达式“今天”,“明天”和“昨天”。

+0

受过教育的猜测这是你的问题。可能没有一个可行的解决方案。如果我不正确,我会删除它。 – Matt

+0

谢谢,我错过了'.CreateDateTime'方法,傻了我。现在得到一个公式错误!战斗继续... – Federer