Get-IMAP Cmdlet
Parameters Output Objects Configuration Settings
The Get-IMAP cmdlet is used to retrieve electronic mail from Internet Message Access (IMAP) servers.
Syntax
Get-IMAP [parameters]
Remarks
This cmdlet implements a standard Internet Message Access Protocol (IMAP) client as specified in RFC 1730 and RFC 2060 for retrieving email and listing mail folders (mailboxes).
To use the cmdlet to retrieve email, you must specify a mail Server, User, and Password. Specify the Folder for the mailbox you wish to connect to. The email message (or range of messages) to download is given by View.
Retrieved email messages will be returned in one or more EmailMessages. Brief information (Id, From, Subject, and size) about each retrieved email will be returned in one or more MessageHeaderss.
You may also list all of your mailboxes by setting the ListFolders switch. Folders will be returned in one or more MailBoxObjects.
To use SSL-enabled (RFC 2595) IMAP, set the SSL switch.
This cmdlet handles retrieving emails and listing email folders. To send an email, see the SEND-EMAIL cmdlet. To delete a message or manage IMAP mail folders, use the SET-IMAP cmdlet.
The cmdlets support pipeline input for some of their parameters. Prebuilding an object and piping it to the cmdlet is very useful, but should be used with caution to prevent security conflicts. Steps have been taken to decrease the risk of a possibly accidental pipe to the cmdlet, for instance, the Credential parameter cannot be piped to the cmdlet and must be specified manually.
# get a list of the mailboxes
get
-imap -server mailserver -credential $cred -listfolders
# list the last 5 messages to arrive from the default mailbox (INBOX)
get
-imap -server mailserver -credential $cred -list 5
# view message number 8320 in the "Archive" mailbox
get
-imap -server mailserver -credential $cred -folder
"INBOX.Archive"
-view 8320
Connection Handling
This cmdlet supports persistent connections through the Connection parameter. To establish a new IMAP connection, use the Connect-IMAP cmdlet. To close the connection, use the Disconnect-IMAP cmdlet.
Parameter List
The following is the full list of the parameters of the cmdlet with short descriptions. Click on the links for further details.
Connection | An already established connection. |
LogFile | The location of a file to which debug information is written. |
ACL | Indicates whether or not to list the mailbox ACLs. |
AttachmentDirectory | Specifies the directory where attachments are downloaded. |
AuthMechanism | The authentication mechanism to be used when connecting to the mail server. |
CertPassword | The password to the certificate store. |
CertStore | The name of the certificate store for the client certificate. |
CertStoreType | The type of certificate store for the client certificate. |
CertSubject | The subject of the certificate used for client authentication. |
Config | Specifies one or more configuration settings. |
Credential | The PSCredential object to use for user/password authentication. |
FirewallHost | Name or IP address of firewall. |
FirewallPassword | A password if authentication is to be used when connecting through the firewall. |
FirewallPort | The port of the firewall to which to connect. |
FirewallType | Determines the type of firewall to connect through. |
FirewallUser | A user name if authentication is to be used connecting through a firewall. |
Folder | The IMAP folder to which to connect. |
Force | Forces the cmdlet to accept the default behavior instead of querying the user. |
HeadersOnly | If true, only message headers will be fetched. |
List | Number of messages to list. |
ListFolders | Indicates whether or not to perform a List Mailboxes operation on the IMAP server. |
LocalFile | Part is stored here if this property is set. |
LocalIP | The IP address of the local interface to use. |
LogFile | The location of a file to which debug information is written. |
Overwrite | Indicates whether the LocalFile may be overwritten. |
Part | If set, the cmdlet will retrieve the content of the part from the server. |
Password | The password to use for authentication. |
Port | The TCP port in the remote host to which to connect. |
Server | The address of the Server. |
SSL | Determines how the cmdlet starts SSL negotiation. |
SSLAccept | The encoded public key of the certificate which is to be trusted explicitly. |
Timeout | The maximum time allowed for the operation. |
User | The username to use for authentication. |
View | The message number to view. |
Output Objects
The following is the full list of the output objects returned by the cmdlet with short descriptions. Click on the links for further details.
ACL | Object containing the access control rights for a specific mailbox. |
IMAPEmailMessage | Object containing the entire text of the email message. |
MailBox | These objects are returned in response to a ListFolders . |
MessageInfo | Object containing brief information about the returned email. |
MessagePart | Returned for the part specified by Part . |
Configuration Settings
The following is a list of configuration settings for the cmdlet with short descriptions. Click on the links for further details.
MessageCount | Number of messages in the mailbox. |
AlwaysReturnUIDs | Instructs the server to return UIDs even if not in UIDMode. |
AppendToMailboxDateTime | Specifies the date-time parameter used in the initial APPEND request. |
AuthorizationIdentity | The value to use as the authorization identity when SASL authentication is used. |
AutoDecodeText | Whether to decode MessageText when AutoDecodeParts is True. |
FetchAfterSearch | Determines if messages matching the SearchCriteria are fetched after calling SearchMailbox. |
IncludeHeaders | Instructs the cmdlet to include the headers in the LocalFile. |
MaskSensitive | Whether sensitive properties should be masked when logging. |
UTF7MailboxNames | Specifies whether or not to automatically encode and decode UTF-7 mailbox names. |
ConnectionTimeout | Sets a separate timeout value for establishing a connection. |
FirewallAutoDetect | Tells the cmdlet whether or not to automatically detect and use firewall system settings, if available. |
FirewallHost | Name or IP address of firewall (optional). |
FirewallPassword | Password to be used if authentication is to be used when connecting through the firewall. |
FirewallPort | The TCP port for the FirewallHost;. |
FirewallType | Determines the type of firewall to connect through. |
FirewallUser | A user name if authentication is to be used connecting through a firewall. |
KeepAliveTime | The inactivity time in milliseconds before a TCP keep-alive packet is sent. |
KeepAliveInterval | The retry interval, in milliseconds, to be used when a TCP keep-alive packet is sent and no response is received. |
Linger | When set to True, connections are terminated gracefully. |
LingerTime | Time in seconds to have the connection linger. |
LocalHost | The name of the local host through which connections are initiated or accepted. |
LocalPort | The port in the local host where the cmdlet binds. |
MaxLineLength | The maximum amount of data to accumulate when no EOL is found. |
MaxTransferRate | The transfer rate limit in bytes per second. |
ProxyExceptionsList | A semicolon separated list of hosts and IPs to bypass when using a proxy. |
TCPKeepAlive | Determines whether or not the keep alive socket option is enabled. |
UseIPv6 | Whether to use IPv6. |
TcpNoDelay | Whether or not to delay when sending packets. |
AbsoluteTimeout | Determines whether timeouts are inactivity timeouts or absolute timeouts. |
FirewallData | Used to send extra data to the firewall. |
InBufferSize | The size in bytes of the incoming queue of the socket. |
OutBufferSize | The size in bytes of the outgoing queue of the socket. |
UseBackgroundThread | Whether threads created by the cmdlet are background threads. |
UseInternalSecurityAPI | Tells the cmdlet whether or not to use the system security libraries or an internal implementation. |