{
  "version": "Notebook/1.0",
  "items": [
    {
      "type": 9,
      "content": {
        "version": "KqlParameterItem/1.0",
        "query": "",
        "crossComponentResources": [],
        "parameters": [
          {
            "id": "fd258da3-1556-41fc-b428-17122a3c8662",
            "version": "KqlParameterItem/1.0",
            "name": "TimeRange",
            "type": 4,
            "isRequired": true,
            "value": {
              "durationMs": 7776000000
            },
            "typeSettings": {
              "selectableValues": [
                {
                  "durationMs": 300000
                },
                {
                  "durationMs": 900000
                },
                {
                  "durationMs": 1800000
                },
                {
                  "durationMs": 3600000
                },
                {
                  "durationMs": 14400000
                },
                {
                  "durationMs": 43200000
                },
                {
                  "durationMs": 86400000
                },
                {
                  "durationMs": 172800000
                },
                {
                  "durationMs": 259200000
                },
                {
                  "durationMs": 604800000
                },
                {
                  "durationMs": 1209600000
                },
                {
                  "durationMs": 2419200000
                },
                {
                  "durationMs": 2592000000
                },
                {
                  "durationMs": 5184000000
                },
                {
                  "durationMs": 7776000000
                }
              ],
              "allowCustom": true
            }
          },
          {
            "id": "69330e1e-2163-4a9c-aaba-4709b3dd8fd4",
            "version": "KqlParameterItem/1.0",
            "name": "Operations",
            "label": "Activities",
            "type": 2,
            "isRequired": true,
            "multiSelect": true,
            "quote": "'",
            "delimiter": ",",
            "query": "OfficeActivity\r\n| where OfficeWorkload == 'Exchange' \r\n| summarize Count = count() by Operation\r\n| order by Count desc, Operation asc\r\n| project Value = Operation, Label = strcat(Operation, ' - ', Count)",
            "value": null,
            "typeSettings": {
              "additionalResourceOptions": [
                "value::all"
              ],
              "selectAllValue": "All"
            },
            "timeContext": {
              "durationMs": 0
            },
            "timeContextFromParameter": "TimeRange",
            "queryType": 0,
            "resourceType": "microsoft.operationalinsights/workspaces"
          }
        ],
        "style": "pills",
        "queryType": 0,
        "resourceType": "microsoft.operationalinsights/workspaces"
      },
      "name": "parameters - 1"
    },
    {
      "type": 1,
      "content": {
        "json": "## Overview "
      },
      "name": "text - 2"
    },
    {
      "type": 3,
      "content": {
        "version": "KqlItem/1.0",
        "query": "OfficeActivity\r\n| where OfficeWorkload == 'Exchange'\r\n//| extend OperationType = case( Operation contains \r\n| where \"{Operations:lable}\" == \"All\" or \"{Operations:lable}\" == \"All\" or Operation in ({Operations})\r\n| summarize count() by Operation, bin(TimeGenerated, 1d)",
        "size": 0,
        "exportToExcelOptions": "visible",
        "title": "Activities, by time",
        "timeContext": {
          "durationMs": 0
        },
        "timeContextFromParameter": "TimeRange",
        "queryType": 0,
        "resourceType": "microsoft.operationalinsights/workspaces",
        "visualization": "barchart"
      },
      "customWidth": "70",
      "name": "query - 0"
    },
    {
      "type": 3,
      "content": {
        "version": "KqlItem/1.0",
        "query": "OfficeActivity \r\n| where OfficeWorkload == 'Exchange' \r\n| where \"{Operations:lable}\" == \"All\" or Operation in ({Operations})\r\n| summarize count() by UserType \r\n//| order by count_",
        "size": 0,
        "exportToExcelOptions": "visible",
        "title": "User type activities",
        "timeContext": {
          "durationMs": 0
        },
        "timeContextFromParameter": "TimeRange",
        "queryType": 0,
        "resourceType": "microsoft.operationalinsights/workspaces",
        "visualization": "piechart"
      },
      "customWidth": "30",
      "name": "query - 3"
    },
    {
      "type": 3,
      "content": {
        "version": "KqlItem/1.0",
        "query": "let data = OfficeActivity\r\n| where OfficeWorkload == 'Exchange' \r\n| where \"{Operations:lable}\" == \"All\" or Operation in ({Operations});\r\nlet appData = data\r\n| summarize TotalCount = count() by UserId\r\n| join kind=inner (data\r\n    | make-series Trend = count() default = 0 on bin(TimeGenerated, 1d) in range({TimeRange:start}, {TimeRange:end}, {TimeRange:grain}) by UserId\r\n    | project-away TimeGenerated) on UserId\r\n| order by TotalCount desc, UserId asc\r\n| project UserId, TotalCount, Trend\r\n| serialize Id = row_number();\r\ndata\r\n| summarize TotalCount = count() by Operation , UserId\r\n| join kind=inner (data\r\n    | make-series Trend = count() default = 0 on bin(TimeGenerated, 1d) in range({TimeRange:start}, {TimeRange:end}, {TimeRange:grain}) by UserId, Operation\r\n    | project-away TimeGenerated) on UserId, Operation\r\n| order by TotalCount desc, UserId asc\r\n| project UserId, Operation, TotalCount, Trend\r\n| serialize Id = row_number(1000000)\r\n| join kind=inner (appData) on UserId\r\n| project Id, Name = Operation, Type = 'Operation', ['Operation Count'] = TotalCount, Trend, ParentId = Id1\r\n| union (appData \r\n    | project Id, Name = UserId, Type = 'UserId', ['Operation Count'] = TotalCount, Trend )\r\n| order by ['Operation Count'] desc, Name asc",
        "size": 0,
        "exportParameterName": "OperationInfo",
        "exportDefaultValue": "{ \"Name\":\"\", \"Type\":\"*\"}",
        "exportToExcelOptions": "visible",
        "title": "User activities",
        "timeContext": {
          "durationMs": 0
        },
        "timeContextFromParameter": "TimeRange",
        "queryType": 0,
        "resourceType": "microsoft.operationalinsights/workspaces",
        "gridSettings": {
          "formatters": [
            {
              "columnMatch": "Id",
              "formatter": 5,
              "formatOptions": {
                "showIcon": true
              }
            },
            {
              "columnMatch": "Name",
              "formatter": 0,
              "formatOptions": {
                "showIcon": true
              }
            },
            {
              "columnMatch": "Type",
              "formatter": 0,
              "formatOptions": {
                "showIcon": true
              }
            },
            {
              "columnMatch": "Operation Count",
              "formatter": 3,
              "formatOptions": {
                "palette": "lightBlue",
                "showIcon": true
              }
            },
            {
              "columnMatch": "Trend",
              "formatter": 9,
              "formatOptions": {
                "min": 0,
                "palette": "blue",
                "showIcon": true
              }
            },
            {
              "columnMatch": "ParentId",
              "formatter": 5,
              "formatOptions": {
                "showIcon": true
              }
            }
          ],
          "filter": true,
          "hierarchySettings": {
            "idColumn": "Id",
            "parentColumn": "ParentId",
            "treeType": 0,
            "expanderColumn": "Name"
          },
          "labelSettings": []
        }
      },
      "customWidth": "70",
      "name": "query - 4"
    },
    {
      "type": 3,
      "content": {
        "version": "KqlItem/1.0",
        "query": "OfficeActivity \r\n| where OfficeWorkload == 'Exchange' and UserType == 'Admin' \r\n| where \"{Operations:lable}\" == \"All\" or Operation in ({Operations})\r\n| summarize count() by Operation ",
        "size": 0,
        "exportToExcelOptions": "visible",
        "title": "Admin activities",
        "timeContext": {
          "durationMs": 0
        },
        "timeContextFromParameter": "TimeRange",
        "queryType": 0,
        "resourceType": "microsoft.operationalinsights/workspaces",
        "visualization": "piechart"
      },
      "customWidth": "30",
      "name": "query - 15"
    },
    {
      "type": 1,
      "content": {
        "json": "---\r\n## Suspicious activities\r\n\r\n## External access activities"
      },
      "name": "text - 5"
    },
    {
      "type": 3,
      "content": {
        "version": "KqlItem/1.0",
        "query": "//Exchange activities that are performed by actors outside your organization - external\r\nlet OI = dynamic({OperationInfo});\r\nOfficeActivity\r\n| where (OI.Type==\"*\" or (OI.Type == 'UserId' and OI.Name == UserId) or (OI.Type == 'Operation' and OI.Name == Operation))\r\n| where OfficeWorkload == 'Exchange'\r\n| where \"{Operations:lable}\" == \"All\" or Operation in ({Operations})\r\n| where ExternalAccess == 'True' \r\n| summarize count() by Operation\r\n | sort by count_",
        "size": 2,
        "exportToExcelOptions": "visible",
        "title": "External access activities, by activities",
        "timeContext": {
          "durationMs": 0
        },
        "timeContextFromParameter": "TimeRange",
        "queryType": 0,
        "resourceType": "microsoft.operationalinsights/workspaces",
        "visualization": "piechart"
      },
      "customWidth": "40",
      "name": "query - 6"
    },
    {
      "type": 3,
      "content": {
        "version": "KqlItem/1.0",
        "query": "//Exchange activities that are performed by actors outside your organization - external\r\nlet OI = dynamic({OperationInfo});\r\nOfficeActivity\r\n| where OfficeWorkload == 'Exchange'\r\n| where (OI.Type==\"*\" or (OI.Type == 'UserId' and OI.Name == UserId) or (OI.Type == 'Operation' and OI.Name == Operation))\r\n| where \"{Operations:lable}\" == \"All\" or Operation in ({Operations})\r\n| where ExternalAccess == 'True' \r\n| summarize Amount = count() by Operation, UserId, UserType, bin(TimeGenerated, 1h)\r\n| project Amount, Activity = Operation, UserId, UserType, TimeGenerated\r\n| order by Amount desc",
        "size": 0,
        "exportToExcelOptions": "visible",
        "timeContext": {
          "durationMs": 0
        },
        "timeContextFromParameter": "TimeRange",
        "queryType": 0,
        "resourceType": "microsoft.operationalinsights/workspaces",
        "gridSettings": {
          "formatters": [
            {
              "columnMatch": "Amount",
              "formatter": 8,
              "formatOptions": {
                "palette": "magenta",
                "showIcon": true,
                "aggregation": "Sum"
              }
            },
            {
              "columnMatch": "Activity",
              "formatter": 5,
              "formatOptions": {
                "showIcon": true
              }
            },
            {
              "columnMatch": "UserId",
              "formatter": 5,
              "formatOptions": {
                "showIcon": true
              }
            },
            {
              "columnMatch": "UserType",
              "formatter": 0,
              "formatOptions": {
                "showIcon": true,
                "aggregation": "Unique"
              }
            },
            {
              "columnMatch": "TimeGenerated",
              "formatter": 0,
              "formatOptions": {
                "showIcon": true
              }
            },
            {
              "columnMatch": "$gen_group",
              "formatter": 0,
              "formatOptions": {
                "showIcon": true
              }
            }
          ],
          "filter": true,
          "hierarchySettings": {
            "treeType": 1,
            "groupBy": [
              "Activity",
              "UserId"
            ]
          },
          "labelSettings": []
        }
      },
      "customWidth": "60",
      "name": "query - 7"
    },
    {
      "type": 3,
      "content": {
        "version": "KqlItem/1.0",
        "query": "//Hard delete operations over time\r\nOfficeActivity\r\n| where OfficeWorkload == 'Exchange' and Operation contains 'HardDelete'\r\n| summarize count() by bin_at(TimeGenerated, 1d, now()), UserId",
        "size": 0,
        "exportToExcelOptions": "visible",
        "title": "Hard delete activities",
        "timeContext": {
          "durationMs": 0
        },
        "timeContextFromParameter": "TimeRange",
        "queryType": 0,
        "resourceType": "microsoft.operationalinsights/workspaces",
        "visualization": "barchart"
      },
      "name": "query - 8"
    },
    {
      "type": 1,
      "content": {
        "json": "---\r\n# Mailbox activities"
      },
      "name": "text - 9"
    },
    {
      "type": 3,
      "content": {
        "version": "KqlItem/1.0",
        "query": "let OperationsData = OfficeActivity\r\n| where Operation in (\"Set-Mailbox\", \"Log-on\", 'Add-MailboxPermission', 'UpdateFolderPermissions', 'Remove-MailboxPermission')\r\n| extend Category = case( Operation == \"Set-Mailbox\", \"Mailbox creation\",\r\n                                Operation == \"Log-on\", \"Log-in\",\r\n                                Operation == \"Add-MailboxPermission\" or Operation == \"UpdateFolderPermissions\" or Operation == \"Remove-MailboxPermission\", \"Permission activities\",\r\n                                \"\");\r\nOperationsData\r\n| summarize Count = count() by Category\r\n| join kind = inner (OperationsData\r\n | make-series Trend = count() default = 0 on bin(TimeGenerated, 1d) from {TimeRange:start} to {TimeRange:end} step {TimeRange:grain} by Category)\r\n on Category\r\n | project-away Category1, TimeGenerated\r\n| extend Categorys = Category\r\n| union (\r\n OperationsData\r\n | summarize Count = count() \r\n | extend jkey = 1\r\n | join kind=inner (OperationsData\r\n | make-series Trend = count() default = 0 on TimeGenerated from {TimeRange:start} to {TimeRange:end} step {TimeRange:grain}\r\n | extend jkey = 1) on jkey\r\n | extend Category = 'All', Categorys = '*' \r\n)\r\n| order by Count desc\r\n| take 10",
        "size": 4,
        "exportToExcelOptions": "visible",
        "timeContext": {
          "durationMs": 0
        },
        "timeContextFromParameter": "TimeRange",
        "queryType": 0,
        "resourceType": "microsoft.operationalinsights/workspaces",
        "visualization": "tiles",
        "tileSettings": {
          "titleContent": {
            "columnMatch": "Category",
            "formatter": 1,
            "formatOptions": {
              "showIcon": true
            }
          },
          "leftContent": {
            "columnMatch": "Count",
            "formatter": 12,
            "formatOptions": {
              "palette": "auto",
              "showIcon": true
            },
            "numberFormat": {
              "unit": 17,
              "options": {
                "style": "decimal",
                "maximumFractionDigits": 2,
                "maximumSignificantDigits": 3
              }
            }
          },
          "secondaryContent": {
            "columnMatch": "Trend",
            "formatter": 9,
            "formatOptions": {
              "palette": "gray",
              "showIcon": true
            }
          },
          "showBorder": false
        }
      },
      "name": "query - 15"
    },
    {
      "type": 3,
      "content": {
        "version": "KqlItem/1.0",
        "query": "//Mailbox Logins by hour\r\nOfficeActivity\r\n| where OfficeWorkload == 'Exchange' and Operation == 'MailboxLogin'\r\n| summarize Logins = count() by bin_at(TimeGenerated, 1h, now())\r\n",
        "size": 0,
        "exportToExcelOptions": "visible",
        "title": "Mailbox logins, by hour",
        "timeContext": {
          "durationMs": 0
        },
        "timeContextFromParameter": "TimeRange",
        "queryType": 0,
        "resourceType": "microsoft.operationalinsights/workspaces",
        "visualization": "timechart"
      },
      "customWidth": "70",
      "name": "query - 10"
    },
    {
      "type": 3,
      "content": {
        "version": "KqlItem/1.0",
        "query": "//The type of mailbox access. (type of user who accessed the mailbox) \r\nOfficeActivity \r\n| where OfficeWorkload == 'Exchange' and Operation == 'MailboxLogin' \r\n| summarize count() by Logon_Type",
        "size": 0,
        "exportToExcelOptions": "visible",
        "title": "Mailbox logins, by user type",
        "timeContext": {
          "durationMs": 0
        },
        "timeContextFromParameter": "TimeRange",
        "queryType": 0,
        "resourceType": "microsoft.operationalinsights/workspaces",
        "visualization": "piechart"
      },
      "customWidth": "30",
      "name": "query - 11"
    },
    {
      "type": 3,
      "content": {
        "version": "KqlItem/1.0",
        "query": "OfficeActivity \r\n| where OfficeWorkload == 'Exchange' and Operation == 'Set-Mailbox' \r\n| project TimeGenerated , UserId , UserType  \r\n",
        "size": 0,
        "exportToExcelOptions": "visible",
        "title": "New mailboxes created",
        "timeContext": {
          "durationMs": 0
        },
        "timeContextFromParameter": "TimeRange",
        "queryType": 0,
        "resourceType": "microsoft.operationalinsights/workspaces",
        "gridSettings": {
          "filter": true,
          "labelSettings": []
        }
      },
      "customWidth": "70",
      "name": "query - 12"
    },
    {
      "type": 3,
      "content": {
        "version": "KqlItem/1.0",
        "query": "//Mailbox permissions changes\r\nOfficeActivity\r\n| where OfficeWorkload == 'Exchange' and Operation in ('Add-MailboxPermission', 'UpdateFolderPermissions', 'Remove-MailboxPermission')\r\n| summarize count() by Operation\r\n| sort by count_",
        "size": 0,
        "exportToExcelOptions": "visible",
        "title": "Mailbox permissions changes",
        "timeContext": {
          "durationMs": 0
        },
        "timeContextFromParameter": "TimeRange",
        "queryType": 0,
        "resourceType": "microsoft.operationalinsights/workspaces",
        "visualization": "piechart"
      },
      "customWidth": "30",
      "name": "query - 13"
    }
  ],
  "styleSettings": {},
  "fromTemplateId": "sentinel-ExchangeOnline",
  "$schema": "https://github.com/Microsoft/Application-Insights-Workbooks/blob/master/schema/workbook.json"
}