EwsExtension Deprecated
Deprecated. Use ***EWS Extension Online Powershell v3*** instead.
Email · Microsoft Exchange Online
Details
| ID | EwsExtension |
|---|---|
| Provider | Microsoft |
| Category | |
| From Version | 5.5.0 |
| Docker Image | demisto/powershell-ubuntu:7.1.4.24032 |
| Supported Modules | Agentix Cloud Runtime Security Cloud Posture Security XSIAM EDR Cortex Cloud |
README
Deprecated. Use EWS Extension Online Powershell v3 instead.
This integration enables you to manage and interact with Microsoft O365 - Exchange Online from within XSOAR.
This integration was integrated and tested with version V1 of Exchange Online PowerShell.
Enable or disable access to Exchange Online PowerShell
Exchange Online PowerShell enables you to manage your Exchange Online organization from the command line.
By default, all accounts you create in Microsoft 365 are allowed to use Exchange Online PowerShell.
Administrators can use Exchange Online PowerShell to enable or disable a user’s ability to connect to Exchange Online PowerShell.
Note that access to Exchange Online PowerShell doesn’t give users extra administrative powers in your organization.
A user’s capabilities in Exchange Online PowerShell are still defined by a role based access control (RBAC) and the roles that are assigned to them.
For more info
Configure O365 - EWS - Extension on Cortex XSOAR
-
Navigate to Settings > Integrations > Servers & Services.
-
Search for O365 - EWS - Extension.
-
Authentication / Authorization methods:
-
OAuth2.0 authorization (recommended):
-
Click Add an instance to create and configure a new integration instance.
Parameter Description Required url Echange online URL True credentials Fill only Email (aka UPN), Password should be empty. False insecure Trust any certificate (not secure) False -
Open playground - War-room:
- Run the !ews-auth-start command and follow the instructions. Expected output is:
EWS extension - Authorize instructions
- To sign in, use a web browser to open the page https://microsoft.com/devicelogin and enter the code XXXXXXX to authenticate.
- Run the command !ews-auth-complete command in the War Room.
- Test - OAuth2.0 authorization, Run the !ews-auth-test command.
-
-
-
Basic authentication (Not recommended):
-
Click Add an instance to create and configure a new integration instance.
Parameter Description Required url Search and Compliance URL True credentials Fill Email (aka UPN) and password False insecure Trust any certificate (not secure) False -
Click Test to validate the URLs, token, and connection.
-
Commands
You can execute these commands from the Cortex XSOAR CLI, as part of an automation, or in a playbook.
After you successfully execute a command, a DBot message appears in the War Room with the command details.
ews-auth-start
OAuth2.0 - Start authorization.
Base Command
ews-auth-start
Input
There are no input arguments for this command.
Context Output
There is no context output for this command.
Command Example
#### Human Readable Output
>## EWS extension - Authorize instructions
>
>1. To sign in, use a web browser to open the page [https://microsoft.com/devicelogin](https://microsoft.com/devicelogin) and enter the code **XXXXXXX** to authenticate.
>2. Run the ***!ews-auth-complete*** command in the War Room.
### ews-auth-complete
***
Completes the OAuth2.0 authorization process.
#### Base Command
`ews-auth-complete`
#### Input
There are no input arguments for this command.
#### Context Output
There is no context output for this command.
#### Command Example
```!ews-auth-complete```
#### Human Readable Output
>Your account **successfully** authorized!
### ews-auth-test
***
Tests the OAuth2.0 authorization process.
#### Base Command
`ews-auth-test`
#### Input
There are no input arguments for this command.
#### Context Output
There is no context output for this command.
#### Command Example
```!ews-auth-test```
#### Human Readable Output
>**Test ok!**
### ews-junk-rules-get
***
Gets junk rules for the specified mailbox.
#### Base Command
`ews-junk-rules-get`
#### Input
| **Argument Name** | **Description** | **Required** |
| --- | --- | --- |
| mailbox | ID of the mailbox for which to get junk rules. | Required |
#### Context Output
| **Path** | **Type** | **Description** |
| --- | --- | --- |
| EWS.Rule.Junk.BlockedSendersAndDomains | String | Blocked senders and domains list. |
| EWS.Rule.Junk.ContactsTrusted | Boolean | If true, contacts are trusted by default. |
| EWS.Rule.Junk.Email | String | Junk rule mailbox. |
| EWS.Rule.Junk.Enabled | Boolean | If true, junk rule is enabled. |
| EWS.Rule.Junk.Identity | String | Junk rule identity. |
| EWS.Rule.Junk.MailboxOwnerId | String | Mail box owner ID. |
| EWS.Rule.Junk.TrustedListsOnly | Boolean | If true, only a list defined in the trusted lists are trusted. |
| EWS.Rule.Junk.TrustedRecipientsAndDomains | String | List of trusted recipients and domains. |
| EWS.Rule.Junk.TrustedSendersAndDomains | String | List of trusted senders and domains. |
#### Command Example
```!ews-junk-rules-get mailbox="xsoar@dev.onmicrosoft.com"```
#### Context Example
```json
{
"EWS": {
"Rule": {
"Junk": {
"BlockedSendersAndDomains": [
"user1@gmail.com",
"user2@gmail.com"
],
"ContactsTrusted": false,
"Enabled": false,
"Identity": "xsoar",
"MailboxOwnerId": "xsoar",
"TrustedListsOnly": false,
"TrustedRecipientsAndDomains": [
"user1@gmail.com",
"user2@gmail.com"
],
"TrustedSendersAndDomains": [
"user1@gmail.com",
"user2@gmail.com"
]
}
}
}
}
Human Readable Output
EWS extension - ‘xsoar@dev.onmicrosoft.com’ Junk rules
BlockedSendersAndDomains ContactsTrusted Enabled TrustedListsOnly TrustedSendersAndDomains [“user1@gmail.com”,”user2@gmail.com”] False False False [“user1@gmail.com”,”user2@gmail.com”]
ews-junk-rules-set
Sets junk rules for the specified mailbox.
Base Command
ews-junk-rules-set
Input
| Argument Name | Description | Required |
|---|---|---|
| mailbox | ID of the mailbox for which to set junk rules. | Required |
| add_blocked_senders_and_domains | Comma-separated list of blocked senders and domains to add to the mailbox. | Optional |
| remove_blocked_senders_and_domains | Comma-separated list of blocked senders and domains to remove from the mailbox. | Optional |
| add_trusted_senders_and_domains | Comma-separated list of trusted senders and domains to add to the mailbox. | Optional |
| remove_trusted_senders_and_domains | Comma-separated list of trusted senders and domains to remove from the mailbox. | Optional |
| trusted_lists_only | If true, trust only lists defined in the trusted lists. Can be “true” or “false”. Possible values are: true, false. | Optional |
| contacts_trusted | If true, contacts are trusted by default. Can be “true” or “false”. Possible values are: true, false. | Optional |
| enabled | If true, the junk rule is enabled. Can be “true” or “false”. Possible values are: true, false. | Optional |
Context Output
There is no context output for this command.
Command Example
!ews-junk-rules-set mailbox="xsoar@dev.onmicrosoft.com" add_blocked_senders_and_domains="test@gmail.com" add_trusted_senders_and_domains="dev.onmicrosoft.com"
Human Readable Output
EWS extension - ‘xsoar@dev.onmicrosoft.com’ Junk rules modified!
ews-global-junk-rules-set
Sets junk rules in all managed accounts.
Base Command
ews-global-junk-rules-set
Input
| Argument Name | Description | Required |
|---|---|---|
| add_blocked_senders_and_domains | Comma-separated list of blocked senders and domains to add to the mailbox. | Optional |
| remove_blocked_senders_and_domains | Comma-separated list of blocked senders and domains to remove from the mailbox. | Optional |
| add_trusted_senders_and_domains | Comma-separated list of trusted senders and domains to add to the mailbox. | Optional |
| remove_trusted_senders_and_domains | Comma-separated list of trusted senders and domains to remove from the mailbox. | Optional |
| trusted_lists_only | If true, trust only lists defined in the trusted lists. Can be “true” or “false”. Possible values are: true, false. | Optional |
| contacts_trusted | If true, contacts are trusted by default. Can be “true” or “false”. Possible values are: true, false. | Optional |
| enabled | If true, the junk rule is enabled. Can be “true” or “false”. Possible values are: true, false. | Optional |
Context Output
There is no context output for this command.
Command Example
!ews-global-junk-rules-set add_blocked_senders_and_domains="test@demisto.com" add_trusted_senders_and_domains="demisto.com"
Human Readable Output
EWS extension - Junk rules globally modified!
ews-message-trace-get
Searches message data for the last 10 days. If you run this command without any arguments, only data from the last 48 hours is returned.
If you enter a start date that is older than 10 days, you will receive an error and the command will return no results.
This command returns a maximum of 1,000,000 results, and will timeout on very large queries. If your query returns too many results, consider splitting it up using shorter start_date and end_date intervals.
Base Command
ews-message-trace-get
Input
| Argument Name | Description | Required |
|---|---|---|
| sender_address | The sender_address parameter filters the results by the sender’s email address. You can specify multiple values separated by commas. . |
Optional |
| recipient_address | The recipient_address parameter filters the results by the recipient’s email address. You can specify multiple values separated by commas. . |
Optional |
| from_ip | The from_ip parameter filters the results by the source IP address. For incoming messages, the value of from_ip is the public IP address of the SMTP email server that sent the message. For outgoing messages from Exchange Online, the value is blank. . |
Optional |
| to_ip | The to_ip parameter filters the results by the destination IP address. For outgoing messages, the value of to_ip is the public IP address in the resolved MX record for the destination domain. For incoming messages to Exchange Online, the value is blank. . |
Optional |
| message_id | The message_id parameter filters the results by the Message-ID header field of the message. This value is also known as the Client ID. The format of the Message-ID depends on the messaging server that sent the message. The value should be unique for each message. However, not all messaging servers create values for the Message-ID in the same way. Be sure to include the full Message ID string (which may include angle brackets) and enclose the value in quotation marks (for example,”d9683b4c-127b-413a-ae2e-fa7dfb32c69d@DM3NAM06BG401.Eop-nam06.prod.protection.outlook.com”). . |
Optional |
| message_trace_id | The message_trace_id parameter can be used with the recipient address to uniquely identify a message trace and obtain more details. A message trace ID is generated for every message that’s processed by the system. . |
Optional |
| page | The page number of the results you want to view. Can be an integer between 1 and 1000. The default value is 1. . Default is 1. |
Optional |
| page_size | The maximum number of entries per page. Can be an integer between 1 and 5000. The default value is 100. . Default is 100. |
Optional |
| start_date | The start date of the date range. Use the short date format that’s defined in the Regional Options settings on the computer where you’re running the command. For example, if the computer is configured to use the short date format mm/dd/yyyy, enter 09/01/2018 to specify September 1, 2018. You can enter the date only, or you can enter the date and time of day. If you enter the date and time of day, enclose the value in quotation marks (“), for example, “09/01/2018 5:00 PM”. Valid input for this parameter is from 10 days - now ago. The default value is 48 hours ago. . |
Optional |
| end_date | The end date of the date range. Use the short date format that’s defined in the Regional Options settings on the computer where you’re running the command. For example, if the computer is configured to use the short date format mm/dd/yyyy, enter 09/01/2018 to specify September 1, 2018. You can enter the date only, or you can enter the date and time of day. If you enter the date and time of day, enclose the value in quotation marks (“), for example, “09/01/2018 5:00 PM”. Valid input for this parameter is from start_date - now. The default value is now. . |
Optional |
| status | The status of the message. Can be one of the following: GettingStatus: The message is waiting for status update. Failed: Message delivery was attempted and it failed or the message was filtered as spam or malware, or by transport rules. Pending: Message delivery is underway or was deferred and is being retried. Delivered: The message was delivered to its destination. Expanded: There was no message delivery because the message was addressed to a distribution group and the membership of the distribution was expanded. Quarantined: The message was quarantined. * FilteredAsSpam: The message was marked as spam. . Possible values are: GettingStatus, Failed, Pending, Delivered, Expanded, Quarantined, FilteredAsSpam. |
Optional |
Context Output
| Path | Type | Description |
|---|---|---|
| EWS.MessageTrace.FromIP | String | The public IP address of the SMTP email server that sent the message. |
| EWS.MessageTrace.ToIP | String | The public IP address in the resolved MX record for the destination domain. For incoming messages to Exchange Online, the value is blank. |
| EWS.MessageTrace.Index | Number | Message index in pagination. (Index starts from 0) |
| EWS.MessageTrace.MessageId | String | Message-ID header field of the message. |
| EWS.MessageTrace.MessageTraceId | String | Message trace ID of the message. |
| EWS.MessageTrace.Organization | String | Message trace organization source. |
| EWS.MessageTrace.Received | Date | Message receive time. |
| EWS.MessageTrace.RecipientAddress | String | Message recipients address. |
| EWS.MessageTrace.SenderAddress | String | Message sender address. |
| EWS.MessageTrace.Size | Number | Message size in bytes. |
| EWS.MessageTrace.StartDate | Date | Message trace start date. |
| EWS.MessageTrace.EndDate | Date | Message trace end date. |
| EWS.MessageTrace.Status | String | Message status. |
| EWS.MessageTrace.Subject | String | Message subject. |
Command Example
Human Readable Output
EWS extension - Messages trace
EndDate FromIP Index MessageId MessageTraceId Organization Received RecipientAddress SenderAddress Size StartDate Status Subject ToIP 1/3/2021 6:14:14 AM 8.8.8.8 0 xxx xxxx microsoft.com 1/3/2021 4:45:36 AM xsoar@dev.microsoft.com xsoar@dev.onmicrosoft.com 6975 1/1/2021 6:14:14 AM Delivered Test mail 1/3/2021 6:15:14 AM 8.8.8.8 1 xxx xxxx microsoft.com 1/3/2021 4:46:36 AM xsoar@dev.microsoft.com xsoar@dev.onmicrosoft.com 6975 1/1/2021 6:15:14 AM Delivered Test mail
ews-federation-trust-get
Displays the federation trust configured for the Exchange organization.
Base Command
ews-federation-trust-get
Input
| Argument Name | Description | Required |
|---|---|---|
| domain_controller | The domain controller identified by its fully qualified domain name (FQDN). For example, dc01.example.com. This argument is available only in on-premises Exchange. | Optional |
| identity | The federation trust ID. If not specified, the command returns all federation trusts configured for the Exchange organization. | Optional |
Context Output
| Path | Type | Description |
|---|---|---|
| EWS.FederationTrust.AdminDisplayName | String | Administrator display name of the federation trust. |
| EWS.FederationTrust.ApplicationIdentifier | String | Application identifier of the federation trust. |
| EWS.FederationTrust.ApplicationUri | String | Application URI of the federation trust. |
| EWS.FederationTrust.DistinguishedName | String | Distinguished name of the federation trust. |
| EWS.FederationTrust.ExchangeObjectId | String | Exchange object ID of the federation trust. |
| EWS.FederationTrust.ExchangeVersion | String | Exchange version of the federation trust. |
| EWS.FederationTrust.Guid | String | GUID of the federation trust. |
| EWS.FederationTrust.Id | String | ID of the federation trust. |
| EWS.FederationTrust.Identity | String | Identity of the federation trust. |
| EWS.FederationTrust.IsValid | Boolean | Whether the federation trust is valid. |
| EWS.FederationTrust.MetadataEpr | String | Metadata EPR of the federation trust. |
| EWS.FederationTrust.MetadataPollInterval | Date | Metadata poll interval of the federation trust. |
| EWS.FederationTrust.MetadataPutEpr | Unknown | Metadata put EPR of the federation trust. |
| EWS.FederationTrust.Name | String | Name of the federation trust. |
| EWS.FederationTrust.NamespaceProvisioner | String | Namespace provisioner of the federation trust. |
| EWS.FederationTrust.ObjectCategory | String | Object category of the federation trust. |
| EWS.FederationTrust.ObjectClass | String | Object class of the federation trust. |
| EWS.FederationTrust.ObjectState | String | Object state of the federation trust. |
| EWS.FederationTrust.OrgCertificate.Archived | Boolean | Whether the organization certificate of the federation trust is archived. |
| EWS.FederationTrust.OrgCertificate.Extensions.Critical | Boolean | Whether the extensions of the organization certificate are critical. |
| EWS.FederationTrust.OrgCertificate.Extensions.Oid.FriendlyName | String | Friendly name of the OID of the organization certificate extensions. |
| EWS.FederationTrust.OrgCertificate.Extensions.Oid.Value | String | Value of the OID of the organization certificate extensions. |
| EWS.FederationTrust.OrgCertificate.Extensions.RawData | Number | Raw data of the organization certificate extensions. |
| EWS.FederationTrust.OrgCertificate.Extensions.SubjectKeyIdentifier | String | Subject key identifier of the organization certificate extensions. |
| EWS.FederationTrust.OrgCertificate.Extensions.KeyUsages | Number | Key usages of the organization certificate extensions. |
| EWS.FederationTrust.OrgCertificate.Extensions.EnhancedKeyUsages.FriendlyName | String | Friendly name of the enhanced key usages of the organization certificate extensions. |
| EWS.FederationTrust.OrgCertificate.Extensions.EnhancedKeyUsages.Value | String | Value of the enhanced key usages of the organization certificate extensions. |
| EWS.FederationTrust.OrgCertificate.Extensions.CertificateAuthority | Boolean | Whether the organization certificate extensions have a certificate authority. |
| EWS.FederationTrust.OrgCertificate.Extensions.HasPathLengthConstraint | Boolean | Whether the organization certificate extensions have a path length constraint. |
| EWS.FederationTrust.OrgCertificate.Extensions.PathLengthConstraint | Number | Path length constraint of the organization certificate extensions. |
| EWS.FederationTrust.OrgCertificate.FriendlyName | String | Friendly name of the organization certificate. |
| EWS.FederationTrust.OrgCertificate.Handle.value | Number | The handle value of the organization certificate. |
| EWS.FederationTrust.OrgCertificate.HasPrivateKey | Boolean | Whether the organization certificate has a private key. |
| EWS.FederationTrust.OrgCertificate.Issuer | String | Issuer of the organization certificate. |
| EWS.FederationTrust.OrgCertificate.IssuerName.Name | String | Name of the issuer of the organization certificate. |
| EWS.FederationTrust.OrgCertificate.IssuerName.Oid.FriendlyName | Unknown | Friendly Name of the OID of the issuer name of the organization certificate. |
| EWS.FederationTrust.OrgCertificate.IssuerName.Oid.Value | Unknown | Value of the OID of the issuer name of the organization certificate. |
| EWS.FederationTrust.OrgCertificate.IssuerName.RawData | Number | Raw data of the issuer name of the organization certificate. |
| EWS.FederationTrust.OrgCertificate.NotAfter | Date | The date until when the organization certificate is valid. |
| EWS.FederationTrust.OrgCertificate.NotBefore | Date | The date the organization certificate became valid. |
| EWS.FederationTrust.OrgCertificate.PrivateKey | Unknown | Private key of the organization certificate. |
| EWS.FederationTrust.OrgCertificate.PublicKey.EncodedKeyValue.Oid.FriendlyName | String | Friendly name of the OID of the encoded key value of the public key. |
| EWS.FederationTrust.OrgCertificate.PublicKey.EncodedKeyValue.Oid.Value | String | Value of the OID of the encoded key value of the public key. |
| EWS.FederationTrust.OrgCertificate.PublicKey.EncodedKeyValue.RawData | Number | Raw data of the encoded key value of the public key. |
| EWS.FederationTrust.OrgCertificate.PublicKey.EncodedParameters.Oid.FriendlyName | String | Friendly name of the OID of the encoded parameters of the public key. |
| EWS.FederationTrust.OrgCertificate.PublicKey.EncodedParameters.Oid.Value | String | Value of the OID of the encoded parameters of the public key. |
| EWS.FederationTrust.OrgCertificate.PublicKey.EncodedParameters.RawData | Number | Raw data of the encoded parameters of the public key. |
| EWS.FederationTrust.OrgCertificate.PublicKey.Key.KeyExchangeAlgorithm | String | Key exchange algorithm of the public key. |
| EWS.FederationTrust.OrgCertificate.PublicKey.Key.LegalKeySizes.MaxSize | Number | Maximum size of the public key. |
| EWS.FederationTrust.OrgCertificate.PublicKey.Key.LegalKeySizes.MinSize | Number | Minimum size of the public key. |
| EWS.FederationTrust.OrgCertificate.PublicKey.Key.LegalKeySizes.SkipSize | Number | SkipSize of the public key. |
| EWS.FederationTrust.OrgCertificate.PublicKey.Key.SignatureAlgorithm | String | Signature algorithm of the public key. |
| EWS.FederationTrust.OrgCertificate.PublicKey.Oid.FriendlyName | String | Friendly name of the OID of the public key. |
| EWS.FederationTrust.OrgCertificate.PublicKey.Oid.Value | String | Value of the OID of the public key. |
| EWS.FederationTrust.OrgCertificate.RawData | Number | Raw data of the organization certificate. |
| EWS.FederationTrust.OrgCertificate.SerialNumber | String | Serial number of the organization certificate. |
| EWS.FederationTrust.OrgCertificate.SignatureAlgorithm.FriendlyName | String | Friendly name of the signature algorithm. |
| EWS.FederationTrust.OrgCertificate.SignatureAlgorithm.Value | String | Value of the signature algorithm. |
| EWS.FederationTrust.OrgCertificate.Subject | String | Subject of the organization certificate. |
| EWS.FederationTrust.OrgCertificate.SubjectName.Name | String | Name of the subject of the organization certificate. |
| EWS.FederationTrust.OrgCertificate.SubjectName.Oid.FriendlyName | Unknown | Friendly name of the OID of the subject name. |
| EWS.FederationTrust.OrgCertificate.SubjectName.Oid.Value | Unknown | Value of the OID of the subject name. |
| EWS.FederationTrust.OrgCertificate.SubjectName.RawData | Number | Raw Data of the subject name. |
| EWS.FederationTrust.OrgCertificate.Thumbprint | String | Thumbprint of the organization certificate. |
| EWS.FederationTrust.OrgCertificate.Version | Number | Version of the organization certificate. |
| EWS.FederationTrust.OrgNextCertificate | Unknown | Next organization certificate. |
| EWS.FederationTrust.OrgNextPrivCertificate | String | Next organization private certificate. |
| EWS.FederationTrust.OrgPrevCertificate.Archived | Boolean | Whether to archive the previous organization certificate. |
| EWS.FederationTrust.OrgPrevCertificate.Extensions.Critical | Boolean | Whether the extensions of the previous organization certificate are critical. |
| EWS.FederationTrust.OrgPrevCertificate.Extensions.Oid.FriendlyName | String | Friendly name of the OID of the previous organization certificate extensions. |
| EWS.FederationTrust.OrgPrevCertificate.Extensions.Oid.Value | String | Value of the OID of the previous organization certificate extensions. |
| EWS.FederationTrust.OrgPrevCertificate.Extensions.RawData | Number | Raw data of the previous organization certificate extensions. |
| EWS.FederationTrust.OrgPrevCertificate.Extensions.SubjectKeyIdentifier | String | Subject key identifier of the previous organization certificate extensions. |
| EWS.FederationTrust.OrgPrevCertificate.Extensions.KeyUsages | Number | Key usages of the previous organization certificate extensions. |
| EWS.FederationTrust.OrgPrevCertificate.Extensions.EnhancedKeyUsages.FriendlyName | String | Friendly name of the enhanced key usages of the previous organization certificate extensions. |
| EWS.FederationTrust.OrgPrevCertificate.Extensions.EnhancedKeyUsages.Value | String | Value of the enhanced key usages of the previous organization certificate extensions. |
| EWS.FederationTrust.OrgPrevCertificate.FriendlyName | String | Friendly name of the previous organization certificate. |
| EWS.FederationTrust.OrgPrevCertificate.Handle.value | Number | Value of the handle of the previous organization certificate. |
| EWS.FederationTrust.OrgPrevCertificate.HasPrivateKey | Boolean | Whether the previous organization certificate has a private key. |
| EWS.FederationTrust.OrgPrevCertificate.Issuer | String | Issuer of the previous organization certificate. |
| EWS.FederationTrust.OrgPrevCertificate.IssuerName.Name | String | Name of the issuer of the previous organization certificate. |
| EWS.FederationTrust.OrgPrevCertificate.IssuerName.Oid.FriendlyName | Unknown | Friendly name of the OID of the issuer of the previous organization certificate. |
| EWS.FederationTrust.OrgPrevCertificate.IssuerName.Oid.Value | Unknown | Value of the OID of the issuer of the previous organization certificate. |
| EWS.FederationTrust.OrgPrevCertificate.IssuerName.RawData | Number | Raw data of the issuer of the previous organization certificate. |
| EWS.FederationTrust.OrgPrevCertificate.NotAfter | Date | The date until when the previous organization certificate is valid. |
| EWS.FederationTrust.OrgPrevCertificate.NotBefore | Date | The date the previous organization certificate became valid. |
| EWS.FederationTrust.OrgPrevCertificate.PrivateKey | Unknown | Private Key of the previous organization certificate. |
| EWS.FederationTrust.OrgPrevCertificate.PublicKey.EncodedKeyValue.Oid.FriendlyName | String | Friendly Name of the OID of the encoded key value of the public key of the previous organization certificate. |
| EWS.FederationTrust.OrgPrevCertificate.PublicKey.EncodedKeyValue.Oid.Value | String | Value of the OID of the encoded key value of the public key of the previous organization certificate. |
| EWS.FederationTrust.OrgPrevCertificate.PublicKey.EncodedKeyValue.RawData | Number | Raw Data of the encoded key value of the public key of the previous organization certificate. |
| EWS.FederationTrust.OrgPrevCertificate.PublicKey.EncodedParameters.Oid.FriendlyName | String | Friendly name of the OID of the encoded parameters of the public key of the previous organization certificate. |
| EWS.FederationTrust.OrgPrevCertificate.PublicKey.EncodedParameters.Oid.Value | String | Value of the OID of the encoded parameters of the public key of the previous organization certificate. |
| EWS.FederationTrust.OrgPrevCertificate.PublicKey.EncodedParameters.RawData | Number | Raw Data of the encoded parameters of the public key of the previous organization certificate. |
| EWS.FederationTrust.OrgPrevCertificate.PublicKey.Key.KeyExchangeAlgorithm | String | Key exchange algorithm of the public key of the previous organization certificate. |
| EWS.FederationTrust.OrgPrevCertificate.PublicKey.Key.LegalKeySizes.MaxSize | Number | Maximum size of the public key of the previous organization certificate. |
| EWS.FederationTrust.OrgPrevCertificate.PublicKey.Key.LegalKeySizes.MinSize | Number | Minimum size of the public key of the previous organization certificate. |
| EWS.FederationTrust.OrgPrevCertificate.PublicKey.Key.LegalKeySizes.SkipSize | Number | SkiPSize of the public key of the previous organization certificate. |
| EWS.FederationTrust.OrgPrevCertificate.PublicKey.Key.SignatureAlgorithm | String | Signature algorithm of the public key of the previous organization certificate. |
| EWS.FederationTrust.OrgPrevCertificate.PublicKey.Oid.FriendlyName | String | Friendly name of the OID of the public key of the previous organization certificate. |
| EWS.FederationTrust.OrgPrevCertificate.PublicKey.Oid.Value | String | Value of the OID of the public key of the previous organization certificate. |
| EWS.FederationTrust.OrgPrevCertificate.RawData | Number | Raw Data of the previous organization certificate. |
| EWS.FederationTrust.OrgPrevCertificate.SerialNumber | String | Serial number of the previous organization certificate. |
| EWS.FederationTrust.OrgPrevCertificate.SignatureAlgorithm.FriendlyName | String | Friendly name of the signature algorithm of the previous organization certificate. |
| EWS.FederationTrust.OrgPrevCertificate.SignatureAlgorithm.Value | String | Value of the signature algorithm of the previous organization certificate. |
| EWS.FederationTrust.OrgPrevCertificate.Subject | String | Subject of the previous organization certificate. |
| EWS.FederationTrust.OrgPrevCertificate.SubjectName.Name | String | Name of the subject of the previous organization certificate. |
| EWS.FederationTrust.OrgPrevCertificate.SubjectName.Oid.FriendlyName | Unknown | Friendly name of the OID of the subject of the previous organization certificate. |
| EWS.FederationTrust.OrgPrevCertificate.SubjectName.Oid.Value | Unknown | Value of the OID of the subject name of the previous organization certificate. |
| EWS.FederationTrust.OrgPrevCertificate.SubjectName.RawData | Number | Raw Data of the subject name of the previous organization certificate. |
| EWS.FederationTrust.OrgPrevCertificate.Thumbprint | String | Thumbprint of the previous organization certificate. |
| EWS.FederationTrust.OrgPrevCertificate.Version | Number | Version of the previous organization certificate. |
| EWS.FederationTrust.OrgPrevPrivCertificate | String | Organization previous private certificate. |
| EWS.FederationTrust.OrgPrivCertificate | String | Organization private certificate. |
| EWS.FederationTrust.OrganizationId | String | Organization ID. |
| EWS.FederationTrust.OriginatingServer | String | Originating server. |
| EWS.FederationTrust.PSComputerName | String | PowerShell computer name. |
| EWS.FederationTrust.PSShowComputerName | Boolean | Whether to show the PowerShell computer name. |
| EWS.FederationTrust.PolicyReferenceUri | String | Policy Reference URI. |
| EWS.FederationTrust.RunspaceId | String | Runspace ID. |
| EWS.FederationTrust.TimesOfUnmatchPartner | Number | Times Of unmatch partner. |
| EWS.FederationTrust.TokenIssuerCertReference | String | Token issuer certificate reference. |
| EWS.FederationTrust.TokenIssuerCertificate.Archived | Boolean | Whether the token issuer certificate is archived. |
| EWS.FederationTrust.TokenIssuerCertificate.Extensions.Critical | Boolean | Whether the extensions of the token issuer certificate are critical. |
| EWS.FederationTrust.TokenIssuerCertificate.Extensions.Oid.FriendlyName | String | Friendly name of the OID of the extensions of the token issuer certificate. |
| EWS.FederationTrust.TokenIssuerCertificate.Extensions.Oid.Value | String | Value of the OID of the extensions of the token issuer certificate. |
| EWS.FederationTrust.TokenIssuerCertificate.Extensions.RawData | Number | Raw Data of the extensions of the token issuer certificate. |
| EWS.FederationTrust.TokenIssuerCertificate.Extensions.SubjectKeyIdentifier | String | Subject key identifier of the extensions of the token issuer certificate. |
| EWS.FederationTrust.TokenIssuerCertificate.Extensions.KeyUsages | Number | Key usages of the extensions of the token issuer certificate. |
| EWS.FederationTrust.TokenIssuerCertificate.FriendlyName | String | Friendly name of the token issuer certificate. |
| EWS.FederationTrust.TokenIssuerCertificate.Handle.value | Number | Value of the handle of the token issuer certificate. |
| EWS.FederationTrust.TokenIssuerCertificate.HasPrivateKey | Boolean | Whether the token issuer certificate has a private key. |
| EWS.FederationTrust.TokenIssuerCertificate.Issuer | String | Issuer of the token issuer certificate. |
| EWS.FederationTrust.TokenIssuerCertificate.IssuerName.Name | String | Name of the issuer of the token issuer certificate. |
| EWS.FederationTrust.TokenIssuerCertificate.IssuerName.Oid.FriendlyName | Unknown | Friendly name of the OID of the token issuer certificate. |
| EWS.FederationTrust.TokenIssuerCertificate.IssuerName.Oid.Value | Unknown | Value of the OID of the issuer of the token issuer certificate. |
| EWS.FederationTrust.TokenIssuerCertificate.IssuerName.RawData | Number | Raw data of the issuer of the token issuer certificate. |
| EWS.FederationTrust.TokenIssuerCertificate.NotAfter | Date | The date until when the token issuer certificate is valid. |
| EWS.FederationTrust.TokenIssuerCertificate.NotBefore | Date | The date the token issuer certificate became valid. |
| EWS.FederationTrust.TokenIssuerCertificate.PrivateKey | Unknown | Private key of the token issuer certificate. |
| EWS.FederationTrust.TokenIssuerCertificate.PublicKey.EncodedKeyValue.Oid.FriendlyName | String | Friendly name of the OID of the encoded key value of the public key of the token issuer certificate. |
| EWS.FederationTrust.TokenIssuerCertificate.PublicKey.EncodedKeyValue.Oid.Value | String | Value of the OID of the encoded key value of the public key of the token issuer certificate. |
| EWS.FederationTrust.TokenIssuerCertificate.PublicKey.EncodedKeyValue.RawData | Number | Raw data of the encoded key value of the public key of the token issuer certificate. |
| EWS.FederationTrust.TokenIssuerCertificate.PublicKey.EncodedParameters.Oid.FriendlyName | String | Friendly name of the OID of the encoded parameters of the public key of the token issuer certificate. |
| EWS.FederationTrust.TokenIssuerCertificate.PublicKey.EncodedParameters.Oid.Value | String | Value of the OID of the encoded parameters of the public key of the token issuer certificate. |
| EWS.FederationTrust.TokenIssuerCertificate.PublicKey.EncodedParameters.RawData | Number | Raw Data of the encoded parameters of the public key of the token issuer certificate. |
| EWS.FederationTrust.TokenIssuerCertificate.PublicKey.Key.KeyExchangeAlgorithm | String | Key exchange algorithm of the public key of the token issuer certificate. |
| EWS.FederationTrust.TokenIssuerCertificate.PublicKey.Key.LegalKeySizes.MaxSize | Number | Maximum size of the public key of the token issuer certificate. |
| EWS.FederationTrust.TokenIssuerCertificate.PublicKey.Key.LegalKeySizes.MinSize | Number | Minimum size of the public key of the token issuer certificate. |
| EWS.FederationTrust.TokenIssuerCertificate.PublicKey.Key.LegalKeySizes.SkipSize | Number | SkiPSize of the public key of the token issuer certificate. |
| EWS.FederationTrust.TokenIssuerCertificate.PublicKey.Key.SignatureAlgorithm | String | Signature algorithm of the public key of the token issuer certificate. |
| EWS.FederationTrust.TokenIssuerCertificate.PublicKey.Oid.FriendlyName | String | Friendly name of the OID of the public key of the token issuer certificate. |
| EWS.FederationTrust.TokenIssuerCertificate.PublicKey.Oid.Value | String | Value of the OID of the public key of the token issuer certificate. |
| EWS.FederationTrust.TokenIssuerCertificate.RawData | Number | Raw Data of the token issuer certificate. |
| EWS.FederationTrust.TokenIssuerCertificate.SerialNumber | String | Serial number of the token issuer certificate. |
| EWS.FederationTrust.TokenIssuerCertificate.SignatureAlgorithm.FriendlyName | String | Friendly name of the signature algorithm of the token issuer certificate. |
| EWS.FederationTrust.TokenIssuerCertificate.SignatureAlgorithm.Value | String | Value of the signature algorithm of the token issuer certificate. |
| EWS.FederationTrust.TokenIssuerCertificate.Subject | String | Subject of the token issuer certificate. |
| EWS.FederationTrust.TokenIssuerCertificate.SubjectName.Name | String | Name of the subject of the token issuer certificate. |
| EWS.FederationTrust.TokenIssuerCertificate.SubjectName.Oid.FriendlyName | Unknown | Friendly name of the OID of the subject of the token issuer certificate. |
| EWS.FederationTrust.TokenIssuerCertificate.SubjectName.Oid.Value | Unknown | Value of the OID of the subject of the token issuer certificate. |
| EWS.FederationTrust.TokenIssuerCertificate.SubjectName.RawData | Number | Raw data of the subject of the token issuer certificate. |
| EWS.FederationTrust.TokenIssuerCertificate.Thumbprint | String | Thumbprint of the token issuer certificate. |
| EWS.FederationTrust.TokenIssuerCertificate.Version | Number | Version of the token issuer certificate. |
| EWS.FederationTrust.TokenIssuerEpr | String | Token issuer EPR. |
| EWS.FederationTrust.TokenIssuerMetadataEpr | String | Token issuer metadata EPR. |
| EWS.FederationTrust.TokenIssuerPrevCertReference | String | Token issuer previous certificate reference. |
| EWS.FederationTrust.TokenIssuerPrevCertificate.Archived | Boolean | Whether the token issuer previous certificate was archived. |
| EWS.FederationTrust.TokenIssuerPrevCertificate.Extensions.Critical | Boolean | Whether the extensions of the token issuer previous certificate was critical. |
| EWS.FederationTrust.TokenIssuerPrevCertificate.Extensions.Oid.FriendlyName | String | Friendly name of the OID of the extensions of the token issuer previous certificate. |
| EWS.FederationTrust.TokenIssuerPrevCertificate.Extensions.Oid.Value | String | Value of the OID of the extensions of the token issuer previous certificate. |
| EWS.FederationTrust.TokenIssuerPrevCertificate.Extensions.RawData | Number | Raw data of the extensions of the token issuer previous certificate. |
| EWS.FederationTrust.TokenIssuerPrevCertificate.Extensions.SubjectKeyIdentifier | String | Subject key identifier of the extensions of the token issuer previous certificate. |
| EWS.FederationTrust.TokenIssuerPrevCertificate.Extensions.KeyUsages | Number | Key usages of the extensions of the token issuer previous certificate. |
| EWS.FederationTrust.TokenIssuerPrevCertificate.FriendlyName | String | Friendly name of the token issuer previous certificate. |
| EWS.FederationTrust.TokenIssuerPrevCertificate.Handle.value | Number | The handle value of the token issuer previous certificate. |
| EWS.FederationTrust.TokenIssuerPrevCertificate.HasPrivateKey | Boolean | Whether the token issuer previous certificate has a private key. |
| EWS.FederationTrust.TokenIssuerPrevCertificate.Issuer | String | Issuer of the token issuer previous certificate. |
| EWS.FederationTrust.TokenIssuerPrevCertificate.IssuerName.Name | String | Name of the issuer of the token issuer previous certificate. |
| EWS.FederationTrust.TokenIssuerPrevCertificate.IssuerName.Oid.FriendlyName | Unknown | Friendly name of the OID of the issuer name of the token issuer previous certificate. |
| EWS.FederationTrust.TokenIssuerPrevCertificate.IssuerName.Oid.Value | Unknown | Value of the OID of the issuer name of the token issuer previous certificate. |
| EWS.FederationTrust.TokenIssuerPrevCertificate.IssuerName.RawData | Number | Raw Data of the issuer name of the token issuer previous certificate. |
| EWS.FederationTrust.TokenIssuerPrevCertificate.NotAfter | Date | The date until when the token issuer previous certificate is valid. |
| EWS.FederationTrust.TokenIssuerPrevCertificate.NotBefore | Date | The date the token issuer previous certificate became valid. |
| EWS.FederationTrust.TokenIssuerPrevCertificate.PrivateKey | Unknown | Private Key of the token issuer previous certificate. |
| EWS.FederationTrust.TokenIssuerPrevCertificate.PublicKey.EncodedKeyValue.Oid.FriendlyName | String | Friendly name of the OID of the encoded key value of the public key of the token issuer previous certificate. |
| EWS.FederationTrust.TokenIssuerPrevCertificate.PublicKey.EncodedKeyValue.Oid.Value | String | Value of the OID of the encoded key value of the public key of the token issuer previous certificate. |
| EWS.FederationTrust.TokenIssuerPrevCertificate.PublicKey.EncodedKeyValue.RawData | Number | Raw data of the encoded key value of the public key of the token issuer previous certificate. |
| EWS.FederationTrust.TokenIssuerPrevCertificate.PublicKey.EncodedParameters.Oid.FriendlyName | String | Friendly name of the OID of the encoded parameters of the public key of the token issuer previous certificate. |
| EWS.FederationTrust.TokenIssuerPrevCertificate.PublicKey.EncodedParameters.Oid.Value | String | Value of the OID of the encoded parameters of the public key of the token issuer previous certificate. |
| EWS.FederationTrust.TokenIssuerPrevCertificate.PublicKey.EncodedParameters.RawData | Number | Raw data of the encoded parameters of the public key of the token issuer previous certificate. |
| EWS.FederationTrust.TokenIssuerPrevCertificate.PublicKey.Key.KeyExchangeAlgorithm | String | Key exchange algorithm of the public key of the token issuer previous certificate. |
| EWS.FederationTrust.TokenIssuerPrevCertificate.PublicKey.Key.LegalKeySizes.MaxSize | Number | Maximum size of the public key of the token issuer previous certificate. |
| EWS.FederationTrust.TokenIssuerPrevCertificate.PublicKey.Key.LegalKeySizes.MinSize | Number | Minimum size of the public key of the token issuer previous certificate. |
| EWS.FederationTrust.TokenIssuerPrevCertificate.PublicKey.Key.LegalKeySizes.SkipSize | Number | SkiPSize of the public key of the token issuer previous certificate. |
| EWS.FederationTrust.TokenIssuerPrevCertificate.PublicKey.Key.SignatureAlgorithm | String | Signature algorithm of the public key of the token issuer previous certificate. |
| EWS.FederationTrust.TokenIssuerPrevCertificate.PublicKey.Oid.FriendlyName | String | Friendly Name of the OID of the public key of the token issuer previous certificate. |
| EWS.FederationTrust.TokenIssuerPrevCertificate.PublicKey.Oid.Value | String | Value of the OID of teh public key of the token issuer previous certificate. |
| EWS.FederationTrust.TokenIssuerPrevCertificate.RawData | Number | Raw Data of the token issuer previous certificate. |
| EWS.FederationTrust.TokenIssuerPrevCertificate.SerialNumber | String | Serial number of the token issuer previous certificate. |
| EWS.FederationTrust.TokenIssuerPrevCertificate.SignatureAlgorithm.FriendlyName | String | Friendly name of the signature algorithm of the token issuer previous certificate. |
| EWS.FederationTrust.TokenIssuerPrevCertificate.SignatureAlgorithm.Value | String | Value of the signature algorithm of the token issuer previous certificate. |
| EWS.FederationTrust.TokenIssuerPrevCertificate.Subject | String | Subject of the token issuer previous certificate. |
| EWS.FederationTrust.TokenIssuerPrevCertificate.SubjectName.Name | String | Name of the subject of the token issuer previous certificate. |
| EWS.FederationTrust.TokenIssuerPrevCertificate.SubjectName.Oid.FriendlyName | Unknown | Friendly Name of the OID of the subject of the token issuer previous certificate. |
| EWS.FederationTrust.TokenIssuerPrevCertificate.SubjectName.Oid.Value | Unknown | Value of the OID of the subject name of the token issuer previous certificate. |
| EWS.FederationTrust.TokenIssuerPrevCertificate.SubjectName.RawData | Number | Raw data of the subject name of the token issuer previous certificate. |
| EWS.FederationTrust.TokenIssuerPrevCertificate.Thumbprint | String | Thumbprint of the token issuer previous certificate. |
| EWS.FederationTrust.TokenIssuerPrevCertificate.Version | Number | Version of the token issuer previous certificate. |
| EWS.FederationTrust.TokenIssuerType | String | Token issuer type of the federation trust. |
| EWS.FederationTrust.TokenIssuerUri | String | Token Issuer UIR of the federation trust. |
| EWS.FederationTrust.WebRequestorRedirectEpr | String | Web requestor redirect EPR of the federation trust. |
| EWS.FederationTrust.WhenChanged | Date | The date the federation trust was changed. |
| EWS.FederationTrust.WhenChangedUTC | Date | The date in UTC format of when the federation trust was changed. |
| EWS.FederationTrust.WhenCreated | Date | The date the federation trust was created. |
| EWS.FederationTrust.WhenCreatedUTC | Date | The date in UTC format of when the federation trust was created. |
ews-federation-configuration-get
Retrieves the Exchange organization’s federated organization identifier and related details, such as federated domains, organization contact, and status.
Base Command
ews-federation-configuration-get
Input
| Argument Name | Description | Required |
|---|---|---|
| domain_controller | The fully qualified domain name (FQDN) of the domain controller. For example, dc01.example.com. This argument is available only in on-premises Exchange. | Optional |
| identity | The federation trust ID. If not specified, all federation trusts configured for the Exchange organization are returned. | Optional |
| include_extended_domain_info | The IncludeExtendedDomainInfo switch specifies that the command query Microsoft Federation Gateway for the status of each accepted domain that’s federated. The status is returned with each domain in the Domains property. Possible values: “true” and “false”. Possible values are: true, false. Default is false. | Optional |
Context Output
| Path | Type | Description |
|---|---|---|
| EWS.FederationConfiguration.AccountNamespace | String | Account namespace of the federation configuration. |
| EWS.FederationConfiguration.DefaultDomain | Unknown | Default domain of the federation configuration. |
| EWS.FederationConfiguration.DelegationTrustLink | String | Delegation trust link of the federation configuration. |
| EWS.FederationConfiguration.DistinguishedName | String | Distinguished name of the federation configuration. |
| EWS.FederationConfiguration.Domains | String | Domains of the federation configuration. |
| EWS.FederationConfiguration.Enabled | Boolean | Whether the federation configuration is enabled. |
| EWS.FederationConfiguration.ExchangeObjectId | String | Exchange object ID of the federation configuration. |
| EWS.FederationConfiguration.ExchangeVersion | String | Exchange version of the federation configuration. |
| EWS.FederationConfiguration.Guid | String | GUID of the federation configuration. |
| EWS.FederationConfiguration.Id | String | ID of the federation configuration. |
| EWS.FederationConfiguration.Identity | String | Identity of the federation configuration. |
| EWS.FederationConfiguration.IsValid | Boolean | Whether the federation configration is valid. |
| EWS.FederationConfiguration.Name | String | Name of the federation configuration. |
| EWS.FederationConfiguration.ObjectCategory | String | Object category of the federation configuration. |
| EWS.FederationConfiguration.ObjectClass | String | Object class of the federation configuration. |
| EWS.FederationConfiguration.ObjectState | String | Object state of the federation configuration. |
| EWS.FederationConfiguration.OrganizationContact | String | Organization contact of the federation configuration. |
| EWS.FederationConfiguration.OrganizationId | String | Organization ID of the federation configuration. |
| EWS.FederationConfiguration.OriginatingServer | String | Originating server of the federation configuration. |
| EWS.FederationConfiguration.PSComputerName | String | PowerShell computer name of the federation configuration. |
| EWS.FederationConfiguration.PSShowComputerName | Boolean | Whether to show the PowerShell computer name of the federation configuration. |
| EWS.FederationConfiguration.RunspaceId | String | Runspace ID of the federation configuration. |
| EWS.FederationConfiguration.WhenChanged | Date | The date the federation configuration was changed. |
| EWS.FederationConfiguration.WhenChangedUTC | Date | The date in UTC format of when the federation configuration was changed. |
| EWS.FederationConfiguration.WhenCreated | Date | The date the federation configuration was created. |
| EWS.FederationConfiguration.WhenCreatedUTC | Date | The date in UTC format of when the federation configuration was created. |
ews-remote-domain-get
Gets the configuration information for the remote domains configured in your organization. This command is available only in the Exchange Online PowerShell V2 module.
Base Command
ews-remote-domain-get
Input
| Argument Name | Description | Required |
|---|---|---|
| domain_controller | The fully qualified domain name (FQDN) of the domain controller. For example, dc01.example.com. This argument is available only in on-premises Exchange. |
Optional |
| identity | The remote domain that you want to view. You can use the GUID, ID, or any other identifier. | Optional |
Context Output
| Path | Type | Description |
|---|---|---|
| EWS.RemoteDomain.AdminDisplayName | String | Admin display name of the remote domain. |
| EWS.RemoteDomain.AllowedOOFType | String | Allowed OOF type of the remote domain. |
| EWS.RemoteDomain.AutoForwardEnabled | Boolean | Whether auto forward is enabled for the remote domain. |
| EWS.RemoteDomain.AutoReplyEnabled | Boolean | Whether auto reply is enabled for the remote domain.. |
| EWS.RemoteDomain.ByteEncoderTypeFor7BitCharsets | String | Byte encoder type For 7-bit charsets of the remote domain. |
| EWS.RemoteDomain.CharacterSet | String | Character set of the remote domain. |
| EWS.RemoteDomain.ContentType | String | Content type of the remote domain. |
| EWS.RemoteDomain.DeliveryReportEnabled | Boolean | Whether delivery report is enabled for the remote domain. |
| EWS.RemoteDomain.DisplaySenderName | Boolean | Whether to display the sender name for the remote domain. |
| EWS.RemoteDomain.DistinguishedName | String | Distinguished name of the remote domain. |
| EWS.RemoteDomain.DomainName | String | Domain name of the remote domain. |
| EWS.RemoteDomain.ExchangeObjectId | String | Exchange object ID of the remote domain. |
| EWS.RemoteDomain.ExchangeVersion | String | Exchange version of the remote domain. |
| EWS.RemoteDomain.Guid | String | GUID of the remote domain. |
| EWS.RemoteDomain.Id | String | ID of the remote domain. |
| EWS.RemoteDomain.Identity | String | Identity of the remote domain. |
| EWS.RemoteDomain.IsInternal | Boolean | Whether the remote domain is internal. |
| EWS.RemoteDomain.IsValid | Boolean | Whether the remote domain is valid. |
| EWS.RemoteDomain.LineWrapSize | String | Line wrap size for the remote domain. |
| EWS.RemoteDomain.MeetingForwardNotificationEnabled | Boolean | Whether meeting forward notification is enabled for the remote domain. |
| EWS.RemoteDomain.MessageCountThreshold | Number | Message count threshold of the remote domain. |
| EWS.RemoteDomain.NDRDiagnosticInfoEnabled | Boolean | Whether NDR diagnostic information is enabled for the remote domain. |
| EWS.RemoteDomain.NDREnabled | Boolean | Whether NDR is enabled for the remote domain. |
| EWS.RemoteDomain.Name | String | Name of the remote domain. |
| EWS.RemoteDomain.NonMimeCharacterSet | String | Non-mime character set of the remote domain. |
| EWS.RemoteDomain.ObjectCategory | String | Object category of the remote domain. |
| EWS.RemoteDomain.ObjectClass | String | Object class of the remote domain. |
| EWS.RemoteDomain.ObjectState | String | Object state of the remote domain. |
| EWS.RemoteDomain.OrganizationId | String | Organization ID of the remote domain. |
| EWS.RemoteDomain.OriginatingServer | String | Originating server of the remote domain. |
| EWS.RemoteDomain.PSComputerName | String | PowerShell computer name of the remote domain. |
| EWS.RemoteDomain.PSShowComputerName | Boolean | Whether to show the PowerShell computer name for the remote domain. |
| EWS.RemoteDomain.PreferredInternetCodePageForShiftJis | String | Preferred internet code page for shift JIS for the remote domain. |
| EWS.RemoteDomain.RequiredCharsetCoverage | Unknown | Required charset coverage for the remote domain. |
| EWS.RemoteDomain.RunspaceId | String | Runspace ID for the remote domain. |
| EWS.RemoteDomain.TNEFEnabled | Unknown | Whether TNEF is enabled for the remote domain. |
| EWS.RemoteDomain.TargetDeliveryDomain | Boolean | Whether the remote domain is used for the target email address of mail users that represent the users in the other forest. |
| EWS.RemoteDomain.TrustedMailInboundEnabled | Boolean | Whether inbound trusted mail is enabled. |
| EWS.RemoteDomain.TrustedMailOutboundEnabled | Boolean | Whether outbound trusted mail is enabled. |
| EWS.RemoteDomain.UseSimpleDisplayName | Boolean | Whether to use the simple display name. |
| EWS.RemoteDomain.WhenChanged | Date | The date the remote domain was changed. |
| EWS.RemoteDomain.WhenChangedUTC | Date | The date in UTC format of when the remote domain was changed. |
| EWS.RemoteDomain.WhenCreated | Date | The date the remote domain was created. |
| EWS.RemoteDomain.WhenCreatedUTC | Date | The date in UTC format of when the remote domain was created. |
ews-user-list
Displays the existing user objects in your organization.
Base Command
ews-user-list
Input
| Argument Name | Description | Required |
|---|---|---|
| identity | The mailbox you want to view. | Optional |
| organizational_unit | The object’s location in Active Directory by which to filter the results. | Optional |
| limit | Maximum number of users to get. A value of 0 means to get all users. Default is 10. | Optional |
Context Output
| Path | Type | Description |
|---|---|---|
| EWS.User.AccountDisabled | Boolean | Whether the user account is disabled. |
| EWS.User.AllowUMCallsFromNonUsers | Boolean | Whether to allow Unified Messaging calls from non-users. |
| EWS.User.ArchiveRelease | String | The archive release of the user object. |
| EWS.User.AssistantName | String | The assistant name of the user object. |
| EWS.User.AuthenticationPolicy | Unknown | The authentication policy of the user object. |
| EWS.User.CanHaveCloudCache | Boolean | Whether the user object can have cloud cache. |
| EWS.User.City | String | The city of the user object. |
| EWS.User.CloudCacheAccountType | String | Cloud cache account type of the user object. |
| EWS.User.CloudCacheProvider | Number | Cloud cache provider of the user object. |
| EWS.User.CloudCacheRemoteEmailAddress | String | Cloud cache remote email address of the user object. |
| EWS.User.CloudCacheScope | Number | Cloud cache scope of the user object. |
| EWS.User.CloudCacheUserName | String | Cloud cache user name of the user object. |
| EWS.User.Company | String | Company of the user object. |
| EWS.User.ConsumerNetID | Unknown | Consumer net ID of the user object. |
| EWS.User.CountryOrRegion | String | Country or region of the . |
| EWS.User.DefaultMailboxWorkloadsMask | Unknown | Default mailbox workloads mask of the user object. |
| EWS.User.Department | String | Department of the user object. |
| EWS.User.DesiredMailboxWorkloads | Unknown | Desired mailbox workloads of the user object. |
| EWS.User.DesiredMailboxWorkloadsGracePeriod | Unknown | Desired mailbox workloads grace period of the user object. |
| EWS.User.DesiredMailboxWorkloadsModified | Unknown | Modified desired mailbox workloads of the user object. |
| EWS.User.DisplayName | String | Display name of the user object. |
| EWS.User.DistinguishedName | String | Distinguished name of the user object. |
| EWS.User.ExchangeObjectId | String | Exchange object ID of the user object. |
| EWS.User.ExchangeVersion | String | Exchange version of the user object. |
| EWS.User.ExternalDirectoryObjectId | String | External Directory Object ID of the user object. |
| EWS.User.Fax | String | Fax of the user object. |
| EWS.User.FirstName | String | First name of the user object. |
| EWS.User.GeoCoordinates | Unknown | Geo coordinates of the user object. |
| EWS.User.Guid | String | GUID of the user object. |
| EWS.User.HomePhone | String | Home phone of the user object. |
| EWS.User.Id | String | ID of the user object. |
| EWS.User.Identity | String | Identity of the user object. |
| EWS.User.Initials | String | Initials of the user object. |
| EWS.User.IsCloudCache | Boolean | Whether there is a cloud cache for the user object. |
| EWS.User.IsCloudCacheBlocked | Boolean | Whether the cloud cache is blocked. |
| EWS.User.IsCloudCacheProvisioningComplete | Boolean | Whether cloud cache provisioning is complete. |
| EWS.User.IsDirSynced | Boolean | Whether the directory is synched. |
| EWS.User.IsInactiveMailbox | Boolean | Whether the mailbox is inactive. |
| EWS.User.IsLinked | Boolean | Whether the user object is linked. |
| EWS.User.IsSecurityPrincipal | Boolean | Whether there is a security principal. |
| EWS.User.IsSoftDeletedByDisable | Boolean | Whether soft delete is disabled and hard (permanent) delete occurs. |
| EWS.User.IsSoftDeletedByRemove | Boolean | When the Exchange Online mailbox is deleted (soft delete), this property is set to True. |
| EWS.User.IsValid | Boolean | Whether the user object is valid. |
| EWS.User.LastName | String | Last name of the user object. |
| EWS.User.LegacyExchangeDN | String | Legacy exchange distinguished name of the user object. |
| EWS.User.LegalAgeGroup | Unknown | Legal age group of the user object. |
| EWS.User.LinkedMasterAccount | String | Linked master account of the user object. |
| EWS.User.MailboxLocations | String | Mailbox locations of the user object. |
| EWS.User.MailboxProvisioningConstraint | Unknown | Mailbox provisioning constraint of the user object. |
| EWS.User.MailboxRegion | Unknown | Mailbox region of the user object. |
| EWS.User.MailboxRegionLastUpdateTime | Unknown | Last time the mailbox region of the user object was updated. |
| EWS.User.MailboxRegionSuffix | String | Mailbox region suffix of the user object. |
| EWS.User.MailboxRelease | String | Mailbox release of the user object. |
| EWS.User.MailboxWorkloads | String | Mailbox workloads of the user object. |
| EWS.User.Manager | Unknown | Manager of the user object. |
| EWS.User.MicrosoftOnlineServicesID | String | Microsoft Online Services ID of the user object. |
| EWS.User.MobilePhone | String | Mobile phone of the user object. |
| EWS.User.Name | String | Name of the user object. |
| EWS.User.NetID | String | Network ID of the user object. |
| EWS.User.Notes | String | Notes for the user object. |
| EWS.User.ObjectCategory | String | Object category of the user object. |
| EWS.User.ObjectClass | String | Object class of the user object. |
| EWS.User.ObjectState | String | Object state of the user object. |
| EWS.User.Office | String | Office of the user object. |
| EWS.User.OrganizationId | String | Organization ID of the user object. |
| EWS.User.OrganizationalUnit | String | Organizational unit of the user object. |
| EWS.User.OriginatingServer | String | Originating server of the user object. |
| EWS.User.PSComputerName | String | PowerShell computer name of the user object. |
| EWS.User.PSShowComputerName | Boolean | Whether to show the PowerShell computer name of the user object. |
| EWS.User.Pager | String | Pager of the user object. |
| EWS.User.Phone | String | Phone of the user object. |
| EWS.User.PhoneticDisplayName | String | Phonetic display name of the user object. |
| EWS.User.PostalCode | String | Postal Code of the user object. |
| EWS.User.PreviousRecipientTypeDetails | String | Details of the previous recipient type of the user object. |
| EWS.User.RecipientType | String | Recipient type of the user object. |
| EWS.User.RecipientTypeDetails | String | Details of the recipient type of the user object. |
| EWS.User.RemotePowerShellEnabled | Boolean | Whether remote PowerShell is enabled for the user object. |
| EWS.User.ResetPasswordOnNextLogon | Boolean | Whether to reset the password on next logon. |
| EWS.User.RunspaceId | String | Runspace ID of the user object. |
| EWS.User.SKUAssigned | Boolean | Whether SKU is assigned. |
| EWS.User.SamAccountName | String | sAMAccountName of the user object. |
| EWS.User.SeniorityIndex | Unknown | Seniority index of the user object. |
| EWS.User.Sid | String | SID of the user object. |
| EWS.User.SimpleDisplayName | String | Simple display name of the user object. |
| EWS.User.StateOrProvince | String | State or province of the user object. |
| EWS.User.StreetAddress | String | Street address of the user object. |
| EWS.User.StsRefreshTokensValidFrom | Date | The validation start date for the Security Token Service (STS) refresh tokens of the user object. |
| EWS.User.TelephoneAssistant | String | Telephone assistant of the user object. |
| EWS.User.Title | String | Title of the user object. |
| EWS.User.UMDialPlan | Unknown | Unified Messaging (UM) dial plan of the user object. |
| EWS.User.UMDtmfMap | String | Unified Messaging (UM) dual tone multi-frequency (DTMF) map of the user object. |
| EWS.User.UpgradeDetails | Unknown | Upgrade details of the user object. |
| EWS.User.UpgradeMessage | Unknown | Upgrade message of the user object. |
| EWS.User.UpgradeRequest | String | Upgrade request of the user object. |
| EWS.User.UpgradeStage | Unknown | Upgrade stage of the user object. |
| EWS.User.UpgradeStageTimeStamp | Unknown | Upgrade stage time stamp of the user object. |
| EWS.User.UpgradeStatus | String | Upgrade status of the user object. |
| EWS.User.UserAccountControl | String | User account control of the user object. |
| EWS.User.UserPrincipalName | String | User principal name of the user object. |
| EWS.User.WebPage | String | Web page of the user object. |
| EWS.User.WhenChanged | Date | The date the user object was changed. |
| EWS.User.WhenChangedUTC | Date | The date in UTC format of when the user object was changed. |
| EWS.User.WhenCreated | Date | The date the user object was created. |
| EWS.User.WhenCreatedUTC | Date | The date in UTC format of when the user object was created. |
| EWS.User.WhenSoftDeleted | Unknown | When the user object was soft deleted. |
| EWS.User.WindowsEmailAddress | String | Windows email address of the user object. |
| EWS.User.WindowsLiveID | String | Windows live ID of the user object. |
| EWS.User.DirectReports | String | Direct reports of the user object. |
ews-mailbox-audit-bypass-association-list
Retrieves information about the AuditBypassEnabled property value for user accounts (on-premises Exchange and the cloud) and computer accounts (on-premises Exchange only).
Base Command
ews-mailbox-audit-bypass-association-list
Input
| Argument Name | Description | Required |
|---|---|---|
| identity | The mailbox you want to view. | Optional |
| domain_controller | The domain controller that’s used by this cmdlet to read data from or write data to Active Directory. You identify the domain controller by its fully qualified domain name (FQDN). This argument is available only in on-premises Exchange. | Optional |
| limit | Maximum number of users to get. A value of 0 means to get all users. Default is 10. | Optional |
Context Output
| Path | Type | Description |
|---|---|---|
| EWS.MailboxAuditBypassAssociation.AuditBypassEnabled | Boolean | Whether the mailbox audit bypass association is enabled. |
| EWS.MailboxAuditBypassAssociation.DistinguishedName | String | Distinguished name of the mailbox audit bypass association. |
| EWS.MailboxAuditBypassAssociation.ExchangeObjectId | String | Exchange object ID of the mailbox audit bypass association. |
| EWS.MailboxAuditBypassAssociation.ExchangeVersion | String | The version of the exchanged server. |
| EWS.MailboxAuditBypassAssociation.Guid | String | The GUID of the mailbox audit bypass association. |
| EWS.MailboxAuditBypassAssociation.Id | String | ID of the mailbox audit bypass association. |
| EWS.MailboxAuditBypassAssociation.Identity | String | The unique identity of the mailbox audit bypass association. |
| EWS.MailboxAuditBypassAssociation.IsValid | Boolean | Whether the mailbox audit bypass association property is enabled. |
| EWS.MailboxAuditBypassAssociation.Name | String | Name of the mailbox audit bypass association. |
| EWS.MailboxAuditBypassAssociation.ObjectCategory | String | Object category of the mailbox audit bypass association. |
| EWS.MailboxAuditBypassAssociation.ObjectClass | String | Object class of the mailbox audit bypass association. |
| EWS.MailboxAuditBypassAssociation.ObjectId | String | Object ID of the mailbox audit bypass association. |
| EWS.MailboxAuditBypassAssociation.ObjectState | String | Object state of the mailbox audit bypass association. |
| EWS.MailboxAuditBypassAssociation.OrganizationId | String | Organization ID of the mailbox audit bypass association. |
| EWS.MailboxAuditBypassAssociation.OriginatingServer | String | Originating server of the mailbox audit bypass association. |
| EWS.MailboxAuditBypassAssociation.PSComputerName | String | PowerShell computer name of the mailbox audit bypass association. |
| EWS.MailboxAuditBypassAssociation.PSShowComputerName | Boolean | Whether to show the computer name of the mailbox audit bypass association. |
| EWS.MailboxAuditBypassAssociation.RunspaceId | String | Runspace ID of the mailbox audit bypass association. |
| EWS.MailboxAuditBypassAssociation.WhenChanged | unknown | The date the mailbox audit bypass association was changed. |
| EWS.MailboxAuditBypassAssociation.WhenChangedUTC | Date | The date in UTC of when the mailbox audit bypass association was changed. |
| EWS.MailboxAuditBypassAssociation.WhenCreated | Date | The date the mailbox audit bypass association was created. |
| EWS.MailboxAuditBypassAssociation.WhenCreatedUTC | Date | The date in UTC format of when the mailbox audit bypass association was created. |
Configuration parameters
url— Exchange Online URL (required)credentials— Email (Password for basic authentication only)insecure— Trust any certificate (not secure)proxy— Use system proxy settings
Commands (12)
-
ews-auth-completeCompletes the OAuth2.0 authorization process.
-
ews-auth-startStarts the OAuth2.0 authorization process.
-
ews-auth-testTests the OAuth2.0 authorization process.
-
ews-federation-configuration-getRetrieves the Exchange organization's federated organization identifier and related details, such as federated domains, organization contact, and status.
-
ews-federation-trust-getDisplays the federation trust configured for the Exchange organization.
-
ews-global-junk-rules-setSets junk rules in all managed accounts.
-
ews-junk-rules-getGets junk rules for the specified mailbox.
-
ews-junk-rules-setSets junk rules for the specified mailbox.
-
ews-mailbox-audit-bypass-association-listRetrieves information about the AuditBypassEnabled property value for user accounts (on-premises Exchange and the cloud) and computer accounts (on-premises Exchange only).
-
ews-message-trace-getSearches message data for the last 10 days. If you run this command without any arguments, only data from the last 48 hours is returned. If you enter a start date that is older than 10 days, you will receive an error and the command will return no results. This command returns a maximum of 1,000,000 results, and will timeout on very large queries. If your query returns too many results, consider splitting it up using shorter start_date and end_date intervals.
-
ews-remote-domain-getGets the configuration information for the remote domains configured in your organization. This command is available only in the Exchange Online PowerShell V2 module.
-
ews-user-listDisplays the existing user objects in your organization.
. $PSScriptRoot\CommonServerPowerShell.ps1 $script:INTEGRATION_NAME = "EWS extension" $script:COMMAND_PREFIX = "ews" $script:INTEGRATION_ENTRY_CONTEXT = "EWS" $script:JUNK_RULE_ENTRY_CONTEXT = "$script:INTEGRATION_ENTRY_CONTEXT.Rule.Junk(val.Email && val.Email == obj.Email)" $script:MESSAGE_TRACE_ENTRY_CONTEXT = "$script:INTEGRATION_ENTRY_CONTEXT.MessageTrace(val.MessageId && val.MessageId == obj.MessageId)" #### HELPER FUNCTIONS #### function UpdateIntegrationContext([OAuth2DeviceCodeClient]$client) { $integration_context = @{ "DeviceCode" = $client.device_code "DeviceCodeExpiresIn" = $client.device_code_expires_in "DeviceCodeCreationTime" = $client.device_code_creation_time "AccessToken" = $client.access_token "RefreshToken" = $client.refresh_token "AccessTokenExpiresIn" = $client.access_token_expires_in "AccessTokenCreationTime" = $client.access_token_creation_time } $Demisto.setIntegrationContext($integration_context) <# .DESCRIPTION Update integration context from OAuth2DeviceCodeClient client .EXAMPLE UpdateIntegrationContext $client .PARAMETER search_name OAuth2DeviceCodeClient client. #> } function CreateNewSession { [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidUsingConvertToSecureStringWithPlainText', '', Scope = 'Function')] [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidUsingPlainTextForPassword', '', Scope = 'Function')] [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSReviewUnusedParameter', '', Scope = 'Function')] param([string]$url, [string]$upn, [string]$password, [string]$bearer_token, [bool]$insecure, [bool]$proxy) if ($password) { $url = "$url/powershell-liveid" } else { $url = "$url/powershell-liveid?BasicAuthToOAuthConversion=true" } if ($password) { $credential = ConvertTo-SecureString "$password" -AsPlainText -Force } else { $credential = ConvertTo-SecureString "Bearer $bearer_token" -AsPlainText -Force } $credential = New-Object System.Management.Automation.PSCredential($upn, $credential) $session_option_params = @{ "SkipCACheck" = $insecure "SkipCNCheck" = $insecure } $session_options = New-PSSessionOption @session_option_params $sessions_params = @{ "ConfigurationName" = "Microsoft.Exchange" "ConnectionUri" = $url "Credential" = $credential "Authentication" = "Basic" "AllowRedirection" = $true "SessionOption" = $session_options } $session = New-PSSession @sessions_params -WarningAction:SilentlyContinue -ShowBanner:$false if (!$session) { throw "Fail - establishing session to $url" } return $session <# .DESCRIPTION Creates new PSSession using Oauth2.0 method. .PARAMETER url Exchange Online url. .PARAMETER upn User Principal Name (UPN) is the name of a system user in an email address format. .PARAMETER password Password is filled only if authentication method is basic auth. .PARAMETER bearer_token Valid bearer token value. .EXAMPLE proxy Wheter to user system proxy configuration or not. .PARAMETER insecure Wheter to trust any TLS/SSL Certificate) or not. .EXAMPLE CreateNewSession("outlook.com", "user@microsoft.com", "dfhsdkjhkjhvkdvbihsgiu") .OUTPUTS PSSession - PSSession object. .LINK https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/new-pssession?view=powershell-7 https://docs.microsoft.com/en-us/powershell/partnercenter/multi-factor-auth?view=partnercenterps-3.0#exchange-online-powershell #> } function ParseJunkRulesToEntryContext([PSObject]$raw_response) { return @{ $script:JUNK_RULE_ENTRY_CONTEXT = @{ "MailboxOwnerId" = $raw_response.MailboxOwnerId "Identity" = $raw_response.Identity "BlockedSendersAndDomains" = $raw_response.BlockedSendersAndDomains "TrustedRecipientsAndDomains" = $raw_response.TrustedRecipientsAndDomains "TrustedSendersAndDomains" = $raw_response.TrustedSendersAndDomains "TrustedListsOnly" = $raw_response.TrustedListsOnly "ContactsTrusted" = $raw_response.ContactsTrusted "Enabled" = $raw_response.Enabled } } <# .DESCRIPTION Parse junk rules raw response. .PARAMETER raw_response Junk rules raw response. .EXAMPLE ParseJunkRulesToEntryContext $raw_response .OUTPUTS PSObject - entry context. #> } function ParseMessageTraceToEntryContext([PSObject]$raw_response) { $entry_context = @{} if ($raw_response) { $entry_context = @{ $script:MESSAGE_TRACE_ENTRY_CONTEXT = $raw_response | ForEach-Object { @{ "MessageId" = $_.MessageId "MessageTraceId" = $_.MessageTraceId "Organization" = $_.Organization "Received" = $_.Received "RecipientAddress" = $_.RecipientAddress "SenderAddress" = $_.SenderAddress "Size" = $_.Size "StartDate" = $_.StartDate "EndDate" = $_.EndDate "Status" = $_.Status "Subject" = $_.Subject "ToIP" = $_.ToIP "FromIP" = $_.FromIP "Index" = $_.Index } } } } return $entry_context <# .DESCRIPTION Parse message trace raw response. .PARAMETER raw_response Message trace raw response. .EXAMPLE ParseMessageTraceToEntryContext $raw_response .OUTPUTS PSObject - entry context. #> } #### OAUTH2.0 CLIENT - DEVICE CODE FLOW ##### class OAuth2DeviceCodeClient { [string]$application_id = "a0c73c16-a7e3-4564-9a95-2bdf47383716" [string]$application_scope = "offline_access%20https%3A//outlook.office365.com/.default" [string]$device_code [int]$device_code_expires_in [int]$device_code_creation_time [string]$access_token [string]$refresh_token [int]$access_token_expires_in [int]$access_token_creation_time [bool]$insecure [bool]$proxy OAuth2DeviceCodeClient([string]$device_code, [string]$device_code_expires_in, [string]$device_code_creation_time, [string]$access_token, [string]$refresh_token, [string]$access_token_expires_in, [string]$access_token_creation_time, [bool]$insecure, [bool]$proxy) { $this.device_code = $device_code $this.device_code_expires_in = $device_code_expires_in $this.device_code_creation_time = $device_code_creation_time $this.access_token = $access_token $this.refresh_token = $refresh_token $this.access_token_expires_in = $access_token_expires_in $this.access_token_creation_time = $access_token_creation_time $this.insecure = $insecure $this.proxy = $proxy <# .DESCRIPTION OAuth2DeviceCodeClient manage state of OAuth2.0 device-code flow described in https://docs.microsoft.com/en-us/azure/active-directory/develop/v2-oauth2-device-code. .DESCRIPTION Its not recommended to create an object using the constructor, Use static method CreateClientFromIntegrationContext() instead. OAuth2DeviceCodeClient states are: 1. Getting device-code (Will be used in stage 2) and user-code (Will be used by the user to authorize permissions) from Microsoft application. 2. Getting access-token and refresh-token - after use authorize (Using stage 1 - device code) 3. Refresh access-token if access-token is expired. .PARAMETER device_code A long string used to verify the session between the client and the authorization server. The client uses this parameter to request the access token from the authorization server. .PARAMETER device_code_expires_in The number of seconds before the device_code and user_code expire. (15 minutes) .PARAMETER access_token Opaque string, Issued for the scopes that were requested. .PARAMETER refresh_token Opaque string, Issued if the original scope parameter included offline_access. (Valid for 90 days) .PARAMETER access_token_expires_in Number of seconds before the included access token is valid for. (Usually - 60 minutes) .PARAMETER access_token_creation_time Unix time of access token creation (Used for knowing when to refresh the token). .PARAMETER access_token_expires_in Number of seconds before the included access token is valid for. (Usually - 60 minutes) .PARAMETER insecure Whether to trust any TLS/SSL Certificate) or not. .PARAMETER proxy Whether to user system proxy configuration or not. .NOTES 1. Application id - a0c73c16-a7e3-4564-9a95-2bdf47383716 , This is well-known application publicly managed by Microsoft and will not work in on-premise environment. .LINK https://docs.microsoft.com/en-us/azure/active-directory/develop/v2-oauth2-device-code #> } static [OAuth2DeviceCodeClient]CreateClientFromIntegrationContext([bool]$insecure, [bool]$proxy) { $ic = $script:Demisto.getIntegrationContext() $client = [OAuth2DeviceCodeClient]::new($ic.DeviceCode, $ic.DeviceCodeExpiresIn, $ic.DeviceCodeCreationTime, $ic.AccessToken, $ic.RefreshToken, $ic.AccessTokenExpiresIn, $ic.AccessTokenCreationTime, $insecure, $proxy) return $client <# .DESCRIPTION Static method which create object (factory method) from populated values in integration context. .EXAMPLE [OAuth2DeviceCodeClient]::CreateClientFromIntegrationContext() .OUTPUTS OAuth2DeviceCodeClient initialized object. #> } [PSObject]AuthorizationRequest() { # Reset object-properties $this.device_code = $null $this.device_code_expires_in = $null $this.device_code_creation_time = $null # Get device-code and user-code $params = @{ "URI" = "https://login.microsoftonline.com/organizations/oauth2/v2.0/devicecode" "Method" = "Post" "Headers" = (New-Object "System.Collections.Generic.Dictionary[[String],[String]]").Add("Content-Type", "application/x-www-form-urlencoded") "Body" = "client_id=$($this.application_id)&scope=$($this.application_scope)" "NoProxy" = !$this.proxy "SkipCertificateCheck" = $this.insecure } $response = Invoke-WebRequest @params $response_body = ConvertFrom-Json $response.Content # Update object properties $this.device_code = $response_body.device_code $this.device_code_creation_time = [int][double]::Parse((Get-Date -UFormat %s)) $this.device_code_expires_in = [int]::Parse($response_body.expires_in) return $response_body <# .DESCRIPTION Reset values populated in instance context and getting new device-code and user-code. .EXAMPLE $client.AuthorizationRequest() .OUTPUTS psobject - Raw body response. .LINK https://docs.microsoft.com/en-us/azure/active-directory/develop/v2-oauth2-device-code#device-authorization-request #> } [psobject]AccessTokenRequest() { # Get new token using device-code try { $params = @{ "URI" = "https://login.microsoftonline.com/organizations/oauth2/v2.0/token" "Method" = "Post" "Headers" = (New-Object "System.Collections.Generic.Dictionary[[String],[String]]").Add("Content-Type", "application/x-www-form-urlencoded") "Body" = "grant_type=urn%3Aietf%3Aparams%3Aoauth%3Agrant-type%3Adevice_code&code=$($this.device_code)&client_id=$($this.application_id)" "NoProxy" = !$this.proxy "SkipCertificateCheck" = $this.insecure } $response = Invoke-WebRequest @params $response_body = ConvertFrom-Json $response.Content } catch { $response_body = ConvertFrom-Json $_.ErrorDetails.Message if ($response_body.error -eq "authorization_pending" -or $response_body.error -eq "invalid_grant") { $error_details = "Please run command !$script:COMMAND_PREFIX-auth-start , before running this command." } elseif ($response_body.error -eq "expired_token") { $error_details = "At least $($this.access_token_expires_in) seconds have passed from executing !$script:COMMAND_PREFIX-auth-start, Please run the ***$script:COMMAND_PREFIX-auth-start*** command again." } else { $error_details = $response_body } throw "Unable to get access token for your account, $error_details" } # Update object properties $this.access_token = $response_body.access_token $this.refresh_token = $response_body.refresh_token $this.access_token_expires_in = [int]::Parse($response_body.expires_in) $this.access_token_creation_time = [int][double]::Parse((Get-Date -UFormat %s)) return $response_body <# .DESCRIPTION Getting access-token and refresh-token from Microsoft application based on the device-code we go from AuthorizationRequest() method. .EXAMPLE $client.AccessTokenRequest() .OUTPUTS psobject - Raw body response. .LINK https://docs.microsoft.com/en-us/azure/active-directory/develop/v2-oauth2-device-code#authenticating-the-user #> } [psobject]RefreshTokenRequest() { # Get new token using refresh token try { $params = @{ "URI" = "https://login.microsoftonline.com/organizations/oauth2/v2.0/token" "Method" = "Post" "Headers" = (New-Object "System.Collections.Generic.Dictionary[[String],[String]]").Add("Content-Type", "application/x-www-form-urlencoded") "Body" = "grant_type=refresh_token&client_id=$($this.application_id)&refresh_token=$($this.refresh_token)&scope=$($this.application_scope)" "NoProxy" = !$this.proxy "SkipCertificateCheck" = $this.insecure } $response = Invoke-WebRequest @params $response_body = ConvertFrom-Json $response.Content } catch { $response_body = ConvertFrom-Json $_.ErrorDetails.Message if ($response_body.error -eq "invalid_grant") { $error_details = "Please login to grant account permissions (After 90 days grant is expired) !$script:COMMAND_PREFIX-auth-start." } else { $error_details = $response_body } throw "Unable to refresh access token for your account, $error_details" } # Update object properties $this.access_token = $response_body.access_token $this.refresh_token = $response_body.refresh_token $this.access_token_expires_in = [int]::Parse($response_body.expires_in) $this.access_token_creation_time = [int][double]::Parse((Get-Date -UFormat %s)) return $response_body <# .DESCRIPTION Getting new access-token and refresh-token from Microsoft application based on the refresh-token we got from AccessTokenRequest() method. .EXAMPLE $client.RefreshTokenRequest() .OUTPUTS PSObject - Raw body response. .LINK https://docs.microsoft.com/en-us/azure/active-directory/develop/v2-oauth2-implicit-grant-flow#refreshing-tokens #> } [bool]IsDeviceCodeExpired() { if (!$this.device_code) { return $true } $current_time = [int][double]::Parse((Get-Date -UFormat %s)) - 30 $valid_until = $this.device_code_creation_time + $this.access_token_expires_in return $current_time -gt $valid_until <# .DESCRIPTION Check if device-code expired. .EXAMPLE $client.IsDeviceCodeExpired() .OUTPUTS bool - True If device-code expired else False. .LINK https://docs.microsoft.com/en-us/azure/active-directory/develop/active-directory-configurable-token-lifetimes#configurable-token-lifetime-properties-after-the-retirement #> } [bool]IsAccessTokenExpired() { if (!$this.access_token) { return $true } $current_time = [int][double]::Parse((Get-Date -UFormat %s)) - 30 $valid_until = $this.access_token_creation_time + $this.access_token_expires_in return $current_time -gt $valid_until <# .DESCRIPTION Check if access-token expired. .EXAMPLE $client.IsAccessTokenExpired() .OUTPUTS bool - True If access-token expired else False. .LINK https://docs.microsoft.com/en-us/azure/active-directory/develop/active-directory-configurable-token-lifetimes#configurable-token-lifetime-properties-after-the-retirement #> } RefreshTokenIfExpired() { if ($this.access_token -and $this.IsAccessTokenExpired()) { $this.RefreshTokenRequest() } <# .DESCRIPTION Refresh access token if expired, with offset of 30 seconds. .EXAMPLE $client.RefreshTokenIfExpired() #> } } #### Security And Compliance client - OAUTH2.0 #### class ExchangeOnlineClient { [string]$url [string]$upn [string]$password [string]$bearer_token [psobject]$session [bool]$insecure [bool]$proxy [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidUsingPlainTextForPassword', '', Scope = 'Function')] ExchangeOnlineClient( [string]$url, [string]$upn, [string]$password, [string]$bearer_token, [bool]$insecure, [bool]$proxy ) { $this.upn = $upn $this.password = $password $this.bearer_token = $bearer_token $this.insecure = $insecure $this.proxy = $proxy $this.url = $url <# .DESCRIPTION ExchangeOnlineClient connect to Exchange Online using power-shell session (OAuth2.0) and allow interact with it. .PARAMETER url Exchange online url. .PARAMETER upn User Principal Name (UPN) is the name of a system user in an email address format. .PARAMETER password Password is filled only if authentication method is basic auth. .PARAMETER bearer_token Valid bearer token value. .PARAMETER insecure Whether to trust any TLS/SSL Certificate) or not. .EXAMPLE proxy Whether to user system proxy configuration or not. .EXAMPLE $exo_client = [ExchangeOnlineClient]::new("outlook.com", "user@microsoft.com", "dfhsdkjhkjhvkdvbihsgiu") #> } CreateSession() { $this.session = CreateNewSession -url $this.url -upn $this.upn -password $this.password -bearer_token $this.bearer_token -insecure $this.insecure -proxy $this.proxy <# .DESCRIPTION This method is for internal use. It creates session to Exchange Online. .EXAMPLE $client.CreateSession() .LINK https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/new-pssession?view=powershell-7 https://docs.microsoft.com/en-us/powershell/partnercenter/multi-factor-auth?view=partnercenterps-3.0#exchange-online-powershell #> } CreateSessionEXOPowershell2() { $this.session = CreateNewSession -url $this.url -upn $this.upn -password $this.password -bearer_token $this.bearer_token -insecure $this.insecure -proxy $this.proxy <# .DESCRIPTION This method is for internal use. It creates session to Exchange Online. .EXAMPLE $client.CreateSession() .LINK https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/new-pssession?view=powershell-7 https://docs.microsoft.com/en-us/powershell/partnercenter/multi-factor-auth?view=partnercenterps-3.0#exchange-online-powershell #> } CloseSession() { if ($this.session) { Remove-PSSession $this.session } <# .DESCRIPTION This method is for internal use. It creates session to Exchange Online. .EXAMPLE $client.CloseSession() .LINK https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/remove-pssession?view=powershell-7 https://docs.microsoft.com/en-us/powershell/partnercenter/multi-factor-auth?view=partnercenterps-3.0#exchange-online-powershell #> } [psobject]GetJunkRules([string]$mailbox) { $response = '' try { # Establish session to remote $this.CreateSession() # Import and Execute command Import-PSSession -Session $this.session -CommandName Get-MailboxJunkEmailConfiguration -AllowClobber $cmd_params = @{ "Identity" = $mailbox } $response = Get-MailboxJunkEmailConfiguration @cmd_params } finally { # Close session to remote $this.CloseSession() } return $response <# .DESCRIPTION Get junk rules in mailbox. .PARAMETER mailbox Mailbox ID. .EXAMPLE $client.GetJunkRules("test@microsoft.com") .OUTPUTS psobject - Raw response. .LINK https://docs.microsoft.com/en-us/powershell/module/exchange/get-mailboxjunkemailconfiguration?view=exchange-ps #> } SetJunkRules([string]$mailbox, [string[]]$add_blocked_senders_and_domains, [string[]]$remove_blocked_senders_and_domains, [string[]]$add_trusted_senders_and_domains, [string[]]$remove_trusted_senders_and_domains, [bool]$trusted_lists_only, [bool]$contacts_trusted, [bool]$enabled) { try { # Establish session to remote $this.CreateSession() # Import and Execute command Import-PSSession -Session $this.session -CommandName Set-MailboxJunkEmailConfiguration -AllowClobber $cmd_params = @{ "Identity" = $mailbox "BlockedSendersAndDomains" = @{Add = $add_blocked_senders_and_domains Remove = $remove_blocked_senders_and_domains } "TrustedSendersAndDomains" = @{Add = $add_trusted_senders_and_domains Remove = $remove_trusted_senders_and_domains } "TrustedListsOnly" = $trusted_lists_only "ContactsTrusted" = $contacts_trusted "Enabled" = $enabled "Confirm" = $false } Set-MailboxJunkEmailConfiguration @cmd_params } finally { # Close session to remote $this.CloseSession() } <# .DESCRIPTION Set junk rules in mailbox. .PARAMETER mailbox Mailbox ID. .PARAMETER add_blocked_senders_and_domains Blocked senders and domains (Comma separated). .PARAMETER remove_blocked_senders_and_domains Blocked senders and domains (Comma separated) to remove. .PARAMETER add_trusted_senders_and_domains Trusted senders and domains (Comma separated). .PARAMETER remove_trusted_senders_and_domains Trusted senders and domains (Comma separated) to remove. .PARAMETER trusted_lists_only Whether to trust only list of defined in trusted lists. .PARAMETER contacts_trusted Whether contacts trusted by default. .PARAMETER enabled Whether junk rule is enabled. .OUTPUTS psobject - Raw response. .LINK https://docs.microsoft.com/en-us/powershell/module/exchange/set-mailboxjunkemailconfiguration?view=exchange-ps #> } SetGlobalJunkRules([string]$mailbox, [string[]]$add_blocked_senders_and_domains, [string[]]$remove_blocked_senders_and_domains, [string[]]$add_trusted_senders_and_domains, [string[]]$remove_trusted_senders_and_domains, [bool]$trusted_lists_only, [bool]$contacts_trusted, [bool]$enabled) { try { # Establish session to remote $this.CreateSession() # Import and Execute command Import-PSSession -Session $this.session -CommandName Set-MailboxJunkEmailConfiguration -AllowClobber Import-PSSession -Session $this.session -CommandName Get-Mailbox -AllowClobber $cmd_params = @{ "BlockedSendersAndDomains" = @{Add = $add_blocked_senders_and_domains Remove = $remove_blocked_senders_and_domains } "TrustedSendersAndDomains" = @{Add = $add_trusted_senders_and_domains Remove = $remove_trusted_senders_and_domains } "TrustedListsOnly" = $trusted_lists_only "ContactsTrusted" = $contacts_trusted "Enabled" = $enabled "Confirm" = $false } Get-Mailbox -RecipientTypeDetails UserMailbox -ResultSize Unlimited | ForEach-Object { Set-MailboxJunkEmailConfiguration -Identity $_.Name @cmd_params } } finally { # Close session to remote $this.CloseSession() } <# .DESCRIPTION Set junk rules in all managed accounts. .PARAMETER add_blocked_senders_and_domains Blocked senders and domains (Comma separated). .PARAMETER remove_blocked_senders_and_domains Blocked senders and domains (Comma separated) to remove. .PARAMETER add_trusted_senders_and_domains Trusted senders and domains (Comma separated). .PARAMETER remove_trusted_senders_and_domains Trusted senders and domains (Comma separated) to remove. .PARAMETER trusted_lists_only Whether to trust only list of defined in trusted lists. .PARAMETER contacts_trusted Whether contacts trusted by default. .PARAMETER enabled Whether junk rule is enabled. .OUTPUTS psobject - Raw response. .LINK https://docs.microsoft.com/en-us/exchange/antispam-and-antimalware/antispam-protection/configure-antispam-settings?view=exchserver-2019 #> } [PSObject]GetMessageTrace([string[]]$sender_address, [string[]]$recipient_address, [string[]]$from_ip, [string[]]$to_ip, [string[]]$message_id, [string]$message_trace_id, [int32]$page, [int32]$page_size, [String]$start_date, [String]$end_date, [string]$status) { $response = "" try { # Establish session to remote $this.CreateSession() # Import and Execute command Import-PSSession -Session $this.session -CommandName Get-MessageTrace -AllowClobber $cmd_params = @{ "SenderAddress" = $sender_address "RecipientAddress" = $recipient_address "Page" = $page "PageSize" = $page_size } if ($status) { $cmd_params.Status = $status } if ($start_date) { $cmd_params.StartDate = $start_date if ($end_date) { $cmd_params.EndDate = $end_date } else { $cmd_params.EndDate = Get-Date -UFormat "%D %I:%M %p" } } if ($from_ip) { $cmd_params.FromIP = $from_ip } if ($to_ip) { $cmd_params.ToIP = $to_ip } if ($message_id) { $cmd_params.MessageId = $message_id } if ($message_trace_id) { $cmd_params.MessageTraceId = $message_trace_id } $response = Get-MessageTrace @cmd_params } finally { # Close session to remote $this.CloseSession() } return $response <# .DESCRIPTION Search message data for the last 10 days. .PARAMETER sender_address The sender_address parameter filters the results by the sender's email address. .PARAMETER recipient_address The recipient_address parameter filters the results by the recipient's email address. You can specify multiple values separated by commas. .PARAMETER from_ip The from_ip parameter filters the results by the source IP address. For incoming messages, the value of from_ip is the public IP address of the SMTP email server that sent the message. For outgoing messages from Exchange Online, the value is blank. .PARAMETER to_ip The to_ip parameter filters the results by the destination IP address. For outgoing messages, the value of to_ip is the public IP address in the resolved MX record for the destination domain. For incoming messages to Exchange Online, the value is blank. .PARAMETER message_id The message_id parameter filters the results by the Message-ID header field of the message. This value is also known as the Client ID. The format of the Message-ID depends on the messaging server that sent the message. The value should be unique for each message. However, not all messaging servers create values for the Message-ID in the same way. Besure to include the full Message ID string (which may include angle brackets) and enclose the value in quotation marks (for example,"d9683b4c-127b-413a-ae2e-fa7dfb32c69d@DM3NAM06BG401.Eop-nam06.prod.protection.outlook.com"). .PARAMETER message_trace_id The message_trace_id parameter can be used with the recipient address to uniquely identify a message trace and obtain more details. A message trace ID is generated for every message that's processed by the system. .PARAMETER page The page parameter specifies the page number of the results you want to view. Valid input for this parameter is an integer between 1 and 1000. The default value is 1. .PARAMETER page_size The page_size parameter specifies the maximum number of entries per page. Valid input for this parameter is an integer between 1 and 5000. The default value is 100. .PARAMETER start_date The start_date parameter specifies the start date of the date range. Use the short date format that's defined in the Regional Options settings on the computer where you're running the command. For example, if the computer is configured to use the short date format mm/dd/yyyy, enter 09/01/2018 to specify September 1, 2018. You can enter the date only, or you can enter the date and time of day. If you enter the date and time of day, enclose the value in quotation marks ("), for example, "09/01/2018 5:00 PM". Valid input for this parameter is from 10 days - now ago. The default value is 48 hours ago. .PARAMETER end_date The end_date parameter specifies the end date of the date range. Use the short date format that's defined in the Regional Options settings on the computer where you're running the command. For example, if the computer is configured to use the short date format mm/dd/yyyy, enter 09/01/2018 to specify September 1, 2018. You can enter the date only, or you can enter the date and time of day. If you enter the date and time of day, enclose the value in quotation marks ("), for example, "09/01/2018 5:00 PM". Valid input for this parameter is from start_date - now. The default value is now. .PARAMETER status * GettingStatus: The message is waiting for status update. * Failed: Message delivery was attempted and it failed or the message was filtered as spam or malware, or by transport rules. * Pending: Message delivery is underway or was deferred and is being retried. * Delivered: The message was delivered to its destination. * Expanded: There was no message delivery because the message was addressed to a distribution group and the membership of the distribution was expanded. * Quarantined: The message was quarantined. * FilteredAsSpam: The message was marked as spam. .OUTPUTS psobject - Raw response. .LINK https://docs.microsoft.com/en-us/powershell/module/exchange/get-messagetrace?view=exchange-ps #> } [PSObject]GetFederationTrust( [string]$domain_controller, [string]$identity ) { $response = "" try { # Establish session to remote $this.CreateSession() # Import and Execute command Import-PSSession -Session $this.session -CommandName Get-FederationTrust -AllowClobber $cmd_params = @{} if ($identity) { $cmd_params.Identity = $identity } if ($domain_controller) { $cmd_params.DomainController = $domain_controller } $response = Get-FederationTrust @cmd_params } finally { $this.CloseSession() } return $response <# .DESCRIPTION Use the Get-FederationTrust cmdlet to view the federation trust configured for the Exchange organization. .PARAMETER domain_controller This parameter is available only in on-premises Exchange. The DomainController parameter specifies the domain controller that's used by this cmdlet to read data from or write data to Active Directory. You identify the domain controller by its fully qualified domain name (FQDN). For example, dc01.contoso.com. .PARAMETER identity The Identity parameter specifies a federation trust ID. If not specified, the cmdlet returns all federation trusts configured for the Exchange organization. .EXAMPLE GetFederationTrust("dc01.contoso.com", "1254y894-feae-9yn7-a3e1-f2483a154tft") .OUTPUTS PSObject - Raw response .LINK https://docs.microsoft.com/en-us/powershell/module/exchange/get-federationtrust?view=exchange-ps #> } [PSObject]GetFederationConfiguration( [string]$domain_controller, [string]$identity, [bool]$include_extended_domain_info ) { $response = "" try { # Establish session to remote $this.CreateSession() # Import and Execute command Import-PSSession -Session $this.session -CommandName Get-FederatedOrganizationIdentifier -AllowClobber $cmd_params = @{} if ($identity) { $cmd_params.Identity = $identity } if ($domain_controller) { $cmd_params.DomainController = $domain_controller } if ($include_extended_domain_info) { $cmd_params.IncludeExtendedDomainInfo = $include_extended_domain_info } $response = Get-FederatedOrganizationIdentifier @cmd_params } finally { $this.CloseSession() } return $response <# .DESCRIPTION Use the Get-FederatedOrganizationIdentifier cmdlet to retrieve the Exchange organization's federated organization identifier and related details, such as federated domains, organization contact and status. .PARAMETER domain_controller This parameter is available only in on-premises Exchange. The DomainController parameter specifies the domain controller that's used by this cmdlet to read data from or write data to Active Directory. You identify the domain controller by its fully qualified domain name (FQDN). For example, dc01.contoso.com. .PARAMETER identity The Identity parameter specifies a federation trust ID. If not specified, the cmdlet returns all federation trusts configured for the Exchange organization. .PARAMETER include_extended_domain_info The IncludeExtendedDomainInfo switch specifies that the command query Microsoft Federation Gateway for the status of each accepted domain that's federated. The status is returned with each domain in the Domains property. .EXAMPLE GetFederationConfiguration("dc01.contoso.com", "1254y894-feae-9yn7-a3e1-f2483a154tft", $true) .OUTPUTS PSObject - Raw response .LINK https://docs.microsoft.com/en-us/powershell/module/exchange/get-federatedorganizationidentifier?view=exchange-ps #> } [PSObject]GetUser( [string]$identity, [string]$organizational_unit, [int]$limit ) { $response = "" try { # Establish session to remote $this.CreateSession() # Import and Execute command Import-PSSession -Session $this.session -CommandName Get-User -AllowClobber $cmd_params = @{ } if ($identity) { $cmd_params.Identity = $identity } if ($organizational_unit) { $cmd_params.OrganizationalUnit = $organizational_unit } if ($limit -gt 0) { $response = Get-User @cmd_params -ResultSize $limit -WarningAction:SilentlyContinue } else { $response = Get-User @cmd_params -ResultSize Unlimited } } finally { $this.CloseSession() } return $response <# .DESCRIPTION Use the Get-User command to view existing user objects in your organization. .PARAMETER identity The Identity parameter the user that you want to view. You can use any value that uniquely identifies the user .PARAMETER orgranizational_unit The OrganizationalUnit parameter filters the results based on the object's location in Active Directory. .EXAMPLE GetUser("user@microsoft.com") .OUTPUTS PSObject - Raw response .LINK https://docs.microsoft.com/en-us/powershell/module/exchange/get-user?view=exchange-ps #> } [PSObject]GetMailboxAuditBypassAssociation( [string]$identity, [string]$domain_controller, [int]$limit ) { $response = "" try { # Establish session to remote $this.CreateSession() # Import and Execute command Import-PSSession -Session $this.session -CommandName Get-MailboxAuditBypassAssociation -AllowClobber $cmd_params = @{ } if ($identity) { $cmd_params.Identity = $identity } if ($domain_controller) { $cmd_params.DomainController = $domain_controller } if ($limit -gt 0){ $cmd_params.ResultSize = $limit } $response = Get-MailboxAuditBypassAssociation @cmd_params -WarningAction:SilentlyContinue } finally { $this.CloseSession() } return $response <# .DESCRIPTION Retrieve information about the AuditBypassEnabled property value for user accounts (on-premises Exchange and the cloud) and computer accounts (on-premises Exchange only). .PARAMETER identity The Identity parameter the user that you want to view. You can use any value that uniquely identifies the user .PARAMETER domain_controller The DomainController parameter specifies the domain controller that's used by this cmdlet to read data from or write data to Active Directory. You identify the domain controller by its fully qualified domain name (FQDN). .EXAMPLE .OUTPUTS PSObject - Raw response .LINK https://docs.microsoft.com/en-us/powershell/module/exchange/get-mailboxauditbypassassociation?view=exchange-ps #> } [PSCustomObject]GetRemoteDomain( [string]$domain_controller, [string]$identity ) { $response = "" try { # Establish session to remote $this.CreateSession() # Import and Execute command Import-PSSession -Session $this.session -CommandName Get-RemoteDomain -AllowClobber $cmd_params = @{} if ($identity) { $cmd_params.Identity = $identity } if ($domain_controller) { $cmd_params.DomainController = $domain_controller } return Get-RemoteDomain @cmd_params -WarningAction:SilentlyContinue } finally { $this.CloseSession() } return $response <# .DESCRIPTION Use the Get-RemoteDomain cmdlet to view the configuration information for the remote domains configured in your organization. .PARAMETER domain_controller This parameter is available only in on-premises Exchange. The DomainController parameter specifies the domain controller that's used by this cmdlet to read data from or write data to Active Directory. You identify the domain controller by its fully qualified domain name (FQDN). For example, dc01.contoso.com. .PARAMETER identity The Identity parameter specifies a federation trust ID. If not specified, the cmdlet returns all federation trusts configured for the Exchange organization. .EXAMPLE GetRemoteDomain("1254y894-feae-9yn7-a3e1-f2483a154tft") .OUTPUTS PSObject - Raw response .LINK https://docs.microsoft.com/en-us/powershell/module/exchange/get-remotedomain?view=exchange-ps #> } } #### COMMAND FUNCTIONS #### function TestModuleCommand ([OAuth2DeviceCodeClient]$oclient, [ExchangeOnlineClient]$exo_client) { try { $exo_client.CreateSession() } finally { $exo_client.CloseSession() } $raw_response = $null $human_readable = "ok" $entry_context = $null return $human_readable, $entry_context, $raw_response } function StartAuthCommand ([OAuth2DeviceCodeClient]$client) { $raw_response = $client.AuthorizationRequest() $human_readable = "## $script:INTEGRATION_NAME - Authorize instructions 1. To sign in, use a web browser to open the page [https://microsoft.com/devicelogin](https://microsoft.com/devicelogin) and enter the code **$($raw_response.user_code)** to authenticate. 2. Run the following command **!$script:COMMAND_PREFIX-auth-complete** in the War Room." $entry_context = @{} return $human_readable, $entry_context, $raw_response } function CompleteAuthCommand ([OAuth2DeviceCodeClient]$client) { # Verify that user run start before complete if (!$client.device_code) { throw "Please run !ews-auth-start and follow the command instructions" } $raw_response = $client.AccessTokenRequest() $human_readable = "Your account **successfully** authorized!" $entry_context = @{} return $human_readable, $entry_context, $raw_response } function TestAuthCommand ([OAuth2DeviceCodeClient]$oclient, [ExchangeOnlineClient]$exo_client) { $raw_response = $oclient.RefreshTokenRequest() $human_readable = "**Test ok!**" $entry_context = @{} try { $exo_client.CreateSession() } finally { $exo_client.CloseSession() } return $human_readable, $entry_context, $raw_response } function GetJunkRulesCommand([ExchangeOnlineClient]$client, [hashtable]$kwargs) { $raw_response = $client.GetJunkRules($kwargs.mailbox) $md_columns = $raw_response | Select-Object -Property BlockedSendersAndDomains, TrustedSendersAndDomains, ContactsTrusted, TrustedListsOnly, Enabled $human_readable = TableToMarkdown $md_columns "$script:INTEGRATION_NAME - '$($kwargs.mailbox)' Junk rules" $entry_context = ParseJunkRulesToEntryContext $raw_response $kwargs.mailbox return $human_readable, $entry_context, $raw_response } function SetJunkRulesCommand([ExchangeOnlineClient]$client, [hashtable]$kwargs) { # Parse arguments $add_blocked_senders_and_domains = ArgToList $kwargs.add_blocked_senders_and_domains $remove_blocked_senders_and_domains = ArgToList $kwargs.remove_blocked_senders_and_domains $add_trusted_senders_and_domains = ArgToList $kwargs.add_trusted_senders_and_domains $remove_trusted_senders_and_domains = ArgToList $kwargs.remove_trusted_senders_and_domains if ($kwargs.trusted_lists_only) { $trusted_lists_only = ConvertTo-Boolean $kwargs.trusted_lists_only } if ($kwargs.contacts_trusted) { $contacts_trusted = ConvertTo-Boolean $kwargs.contacts_trusted } if ($kwargs.enabled) { $enabled = ConvertTo-Boolean $kwargs.enabled } # Execute commands - No output for the command $client.SetJunkRules($kwargs.mailbox, $add_blocked_senders_and_domains, $remove_blocked_senders_and_domains, $add_trusted_senders_and_domains, $remove_trusted_senders_and_domains, $trusted_lists_only, $contacts_trusted, $enabled) $raw_response = @{} $human_readable = "$script:INTEGRATION_NAME - '$($kwargs.mailbox)' Junk rules **modified**!" $entry_context = @{} return $human_readable, $entry_context, $raw_response } function SetGlobalJunkRulesCommand([ExchangeOnlineClient]$client, [hashtable]$kwargs) { # Parse arguments $add_blocked_senders_and_domains = ArgToList $kwargs.add_blocked_senders_and_domains $remove_blocked_senders_and_domains = ArgToList $kwargs.remove_blocked_senders_and_domains $add_trusted_senders_and_domains = ArgToList $kwargs.add_trusted_senders_and_domains $remove_trusted_senders_and_domains = ArgToList $kwargs.remove_trusted_senders_and_domains if ($kwargs.trusted_lists_only) { $trusted_lists_only = ConvertTo-Boolean $kwargs.trusted_lists_only } if ($kwargs.contacts_trusted) { $contacts_trusted = ConvertTo-Boolean $kwargs.contacts_trusted } if ($kwargs.enabled) { $enabled = ConvertTo-Boolean $kwargs.enabled } # Execute commands - No output for the command $client.SetGlobalJunkRules($kwargs.mailbox, $add_blocked_senders_and_domains, $remove_blocked_senders_and_domains, $add_trusted_senders_and_domains, $remove_trusted_senders_and_domains, $trusted_lists_only, $contacts_trusted, $enabled) $raw_response = @{} $human_readable = "$script:INTEGRATION_NAME - Junk rules globally **modified**!" $entry_context = @{} return $human_readable, $entry_context, $raw_response } function GetMessageTraceCommand([ExchangeOnlineClient]$client, [hashtable]$kwargs) { # Parse arguments $sender_address = ArgToList $kwargs.sender_address $recipient_address = ArgToList $kwargs.recipient_address $from_ip = ArgToList $kwargs.from_ip $to_ip = ArgToList $kwargs.to_ip $raw_response = $client.GetMessageTrace($sender_address, $recipient_address, $from_ip, $to_ip, $kwargs.message_id, $kwargs.message_trace_id, $kwargs.page, $kwargs.page_size, $kwargs.start_date, $kwargs.end_date, $kwargs.status) $entry_context = ParseMessageTraceToEntryContext $raw_response if ($entry_context.($script:MESSAGE_TRACE_ENTRY_CONTEXT)) { $human_readable = TableToMarkdown $entry_context.($script:MESSAGE_TRACE_ENTRY_CONTEXT) "$script:INTEGRATION_NAME - Messages trace" } else { $human_readable = "**No messages trace found**" } return $human_readable, $entry_context, $raw_response } function GetFederationTrustCommand([ExchangeOnlineClient]$client, [hashtable]$kwargs) { [CmdletBinding()] # parse arguments $domain_controller = $kwargs.domain_controller $identity = $kwargs.identity $raw_response = $client.GetFederationTrust( $domain_controller, $identity ) $human_readable = TableToMarkdown $raw_response "Results of $command" $entry_context = @{ "$script:INTEGRATION_ENTRY_CONTEXT.FederationTrust(obj.ApplicationIdentifier === val.ApplicationIdentifier)" = $raw_response } Write-Output $human_readable, $entry_context, $raw_response } function GetFederationConfigurationCommand { [CmdletBinding()] param ( [Parameter(Mandatory)] [ExchangeOnlineClient]$client, [hashtable]$kwargs ) # parse arguments $domain_controller = $kwargs.domain_controller $identity = $kwargs.identity $include_extended_domain_info = ConvertTo-Boolean $kwargs.include_extended_domain_info $raw_response = $client.GetFederationConfiguration( $domain_controller, $identity, $include_extended_domain_info ) $human_readable = TableToMarkdown $raw_response "Results of $command" $entry_context = @{ "$script:INTEGRATION_ENTRY_CONTEXT.FederationConfiguration(obj.Guid === val.Guid)" = $raw_response } Write-Output $human_readable, $entry_context, $raw_response } function GetRemoteDomainCommand { [CmdletBinding()] param ( [Parameter(Mandatory)][ExchangeOnlineClient]$client, [hashtable]$kwargs ) $identity = $kwargs.identity $domain_controller = $kwargs.domain_controller $raw_response = $client.GetRemoteDomain($domain_controller, $identity) $human_readable = TableToMarkdown $raw_response "Results of $command" $entry_context = @{"$script:INTEGRATION_ENTRY_CONTEXT.RemoteDomain(obj.Guid === val.Guid)" = $raw_response } Write-Output $human_readable, $entry_context, $raw_response } function GetUserCommand { [CmdletBinding()] param ( [Parameter(Mandatory)][ExchangeOnlineClient]$client, [hashtable]$kwargs ) $identity = $kwargs.identity $organizational_unit = $kwargs.organizational_unit $limit = ($kwargs.limit -as [int]) $raw_response = $client.GetUser($identity, $organizational_unit, $limit) $human_readable = TableToMarkdown $raw_response "Results of $command" $entry_context = @{"$script:INTEGRATION_ENTRY_CONTEXT.User(obj.Guid === val.Guid)" = $raw_response} Write-Output $human_readable, $entry_context, $raw_response } function GetMailboxAuditBypassAssociationCommand { [CmdletBinding()] param ( [Parameter(Mandatory)][ExchangeOnlineClient]$client, [hashtable]$kwargs ) $identity = $kwargs.identity $domain_controller = $kwargs.domain_controller $limit = ($kwargs.limit -as [int]) $raw_response = $client.GetMailboxAuditBypassAssociation($identity, $domain_controller, $limit) $human_readable = TableToMarkdown $raw_response "Results of $command" $entry_context = @{"$script:INTEGRATION_ENTRY_CONTEXT.MailboxAuditBypassAssociation(obj.Guid === val.Guid)" = $raw_response } Write-Output $human_readable, $entry_context, $raw_response } #### INTEGRATION COMMANDS MANAGER #### function Main { $command = $Demisto.GetCommand() $command_arguments = $Demisto.Args() $integration_params = $Demisto.Params() $insecure = (ConvertTo-Boolean $integration_params.insecure) $proxy = (ConvertTo-Boolean $integration_params.proxy) try { # Creating Compliance and search client $oauth2_client = [OAuth2DeviceCodeClient]::CreateClientFromIntegrationContext($insecure, $no_proxy) # Refreshing tokens if expired $oauth2_client.RefreshTokenIfExpired() # Creating ExchangeOnline client $exo_client = [ExchangeOnlineClient]::new( $integration_params.url, $integration_params.credentials.identifier, $integration_params.credentials.password, $oauth2_client.access_token, $insecure, $proxy ) # Executing command $Demisto.Debug("Command being called is $Command") switch ($command) { "test-module" { ($human_readable, $entry_context, $raw_response) = TestModuleCommand $oauth2_client $exo_client } "$script:COMMAND_PREFIX-auth-start" { ($human_readable, $entry_context, $raw_response) = StartAuthCommand $oauth2_client } "$script:COMMAND_PREFIX-auth-complete" { ($human_readable, $entry_context, $raw_response) = CompleteAuthCommand $oauth2_client } "$script:COMMAND_PREFIX-auth-test" { ($human_readable, $entry_context, $raw_response) = TestAuthCommand $oauth2_client $exo_client } "$script:COMMAND_PREFIX-junk-rules-get" { ($human_readable, $entry_context, $raw_response) = GetJunkRulesCommand $exo_client $command_arguments } "$script:COMMAND_PREFIX-junk-rules-set" { ($human_readable, $entry_context, $raw_response) = SetJunkRulesCommand $exo_client $command_arguments } "$script:COMMAND_PREFIX-global-junk-rules-set" { ($human_readable, $entry_context, $raw_response) = SetGlobalJunkRulesCommand $exo_client $command_arguments } "$script:COMMAND_PREFIX-message-trace-get" { ($human_readable, $entry_context, $raw_response) = GetMessageTraceCommand $exo_client $command_arguments } "$script:COMMAND_PREFIX-federation-trust-get" { ($human_readable, $entry_context, $raw_response) = GetFederationTrustCommand $exo_client $command_arguments } "$script:COMMAND_PREFIX-federation-configuration-get" { ($human_readable, $entry_context, $raw_response) = GetFederationConfigurationCommand $exo_client $command_arguments } "$script:COMMAND_PREFIX-remote-domain-get" { ($human_readable, $entry_context, $raw_response) = GetRemoteDomainCommand $exo_client $command_arguments } "$script:COMMAND_PREFIX-user-list" { ($human_readable, $entry_context, $raw_response) = GetUserCommand $exo_client $command_arguments } "$script:COMMAND_PREFIX-mailbox-audit-bypass-association-list" { ($human_readable, $entry_context, $raw_response) = GetMailboxAuditBypassAssociationCommand $exo_client $command_arguments } default { ReturnError "Could not recognize $command" } } # Updating integration context if access token changed UpdateIntegrationContext $oauth2_client # Return results to Demisto Server ReturnOutputs $human_readable $entry_context $raw_response | Out-Null } catch { $Demisto.debug("Integration: $script:INTEGRATION_NAME Command: $command Arguments: $($command_arguments | ConvertTo-Json) Error: $($_.Exception.Message)") if ($command -ne "test-module") { ReturnError "Error: Integration: $script:INTEGRATION_NAME Command: $command Arguments: $($command_arguments | ConvertTo-Json) Error: $($_.Exception)" | Out-Null } else { ReturnError $_.Exception.Message } } } # Execute Main when not in Tests if ($MyInvocation.ScriptName -notlike "*.tests.ps1" -AND -NOT $Test) { Main }