【问题标题】:Search a Lotus Notes database from PowerShell从 PowerShell 搜索 Lotus Notes 数据库
【发布时间】:2017-02-20 13:05:57
【问题描述】:

我正在尝试从 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)

任何人都可以发现错误吗?我认为错误与日期参数有关,因此我进行了多次尝试。

【问题讨论】:

    标签: powershell lotus-notes


    【解决方案1】:

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

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

    我无法对此进行测试,也不确定如何从将 $null 传递给 CreateDateTime 方法的情况下获得 null 返回。

    Unsure if this is the correct reference for the COM implementation 但来自参数部分

    您希望对象表示的日期和时间。如果使用空字符串 (""),则日期设置为通配符日期。支持 Notes 日期时间表达式“今天”、“明天”和“昨天”。

    【讨论】:

    • 受过教育的猜测这是你的问题。虽然可能没有可行的解决方案。如果我不正确,我会删除它。
    • 谢谢,我错过了.CreateDateTime 方法,真傻。现在出现公式错误!战斗还在继续……
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-06-27
    • 2011-07-27
    • 1970-01-01
    相关资源
    最近更新 更多