Skip to content
This repository was archived by the owner on Feb 2, 2019. It is now read-only.
This repository was archived by the owner on Feb 2, 2019. It is now read-only.

Can't use -On or -After in simple scripts on diff versions #7

@AliRazeghi

Description

@AliRazeghi

I tried this on Powershell 2 and Powershell 4 on Windows Server 2008 and Windows 7 using different PCs.

This is a sample code:
$EmailUser = 'Test@GMail.Com'
$EmailUser2 = 'Test@Test.Com'
$EmailSubject = "isAlive"
$pw = [System.Convert]::FromBase64String("Base64Password")
$pw = [System.Text.Encoding]::UTF8.GetString($pw)

$secpasswd = ConvertTo-SecureString $pw -AsPlainText -Force
$mycreds = New-Object System.Management.Automation.PSCredential ($EmailUser, $secpasswd)
$gmail = New-GmailSession -Credential $mycreds

$inbox = $gmail | Get-Mailbox
$inbox | Get-Message -Before "2014-11-30" ## This works fine.
$inbox | Get-Message -After "2014-11-30" ## This does not work.

Using -After gives us this error:

"Exception calling "Search" with "1" argument(s): "xm003 BAD Could not parse command"
At C:\Windows\system32\WindowsPowerShell\v1.0\Modules\Gmail.ps\Gmail.ps.psm1:344 char:5

  • $result = $Session.Search('(' + $criteria + ')');
    
  • ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : NotSpecified: (:) [], MethodInvocationException
    • FullyQualifiedErrorId : Exception
      "

Using -On gives us this error:
GetRFC2060Date : Cannot process argument transformation on parameter 'date'. Cannot convert null to type "System.DateTime".
At C:\Windows\system32\WindowsPowerShell\v1.0\Modules\Gmail.ps\Gmail.ps.psm1:276 char:44

  •     $imap += 'ON "' + $(GetRFC2060Date $After) + '"'
    
  •                                        ~~~~~~
    
    • CategoryInfo : InvalidData: (:) [GetRFC2060Date], ParameterBindingArgumentTransformationException
    • FullyQualifiedErrorId : ParameterArgumentTransformationError,GetRFC2060Date"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions