You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
`tableCreator.ps1` is a PowerShell script designed to streamline the process of duplicating the schema of an existing Microsoft Sentinel table and creating a new table with the same schema. The script supports Analytics, Data Lake, Auxiliary and Basic table types. This tool is ideal for scenarios such as streaming the logs to table with different/cheaper plan or splitting log to multiple tables.
9
+
`tableCreator.ps1` is a PowerShell script designed to streamline the process of duplicating the schema of an existing Microsoft Sentinel table and creating a new table with the same schema. Alternatively, you can bring your own schema via a JSON file (BYOS - bring-your-own-schema). The script supports Analytics, Data Lake, Auxiliary and Basic table types. This tool is ideal for scenarios such as streaming the logs to table with different/cheaper plan or splitting log to multiple tables.
8
10
9
11
## Key Features
10
12
11
13
-**Data Lake Table Creation:** Easily create new tables with the same schema as existing tables.
12
14
-**Schema Duplication:** Automatically capture and reuse the schema from any existing Sentinel table.
15
+
-**Bring-Your-Own-Schema (BYOS):** Create tables using a custom JSON schema file instead of copying from existing tables.
13
16
-**Flexible Table Types:** Supports Analytics, Data Lake, Auxiliary and Basic types.
14
17
-**Retention Settings:** Define both interactive and total retention periods for new tables.
15
18
-**Dynamic Column Handling:** Optionally convert dynamic columns to string for compatibility with Data Lake and Auxiliary tables.
16
19
-**Interactive & Command-Line Modes:** Use prompts for missing parameters or provide all options via command line.
17
20
-**Resource Targeting:** Specify your Sentinel workspace via parameter or prompt.
18
-
-**Tenant Selection:** Use `-tenantId` for authentication outside Azure Cloud Shell.
21
+
-**Tenant Selection:** Use `-TenantId` for authentication outside Azure Cloud Shell.
19
22
20
23
## Usage
21
24
22
25
### 1. Define Your Sentinel Resource ID
23
26
27
+
To obtain full resource ID, go to log analytics workspace and either choose "JSON view" in overview or go to "Properties".<br>
24
28
You can provide the resource ID in two ways:
25
29
26
30
-**Command-Line:**
@@ -51,7 +55,7 @@ You will be prompted for the source table name, new table name, table type, and
The schema file should be a JSON array containing objects with `name` and `type` properties:
81
+
```json
82
+
[
83
+
{"name": "TimeGenerated", "type": "datetime"},
84
+
{"name": "Action", "type": "string"},
85
+
{"name": "Status", "type": "int"}
86
+
]
87
+
```
88
+
64
89
### Parameters
65
90
66
-
-`-FullResourceId` : (Optional) Full Azure Resource ID of the Sentinel workspace.
67
-
-`-tableName` : Name of the existing table to copy schema from.
91
+
-`-FullResourceId` : Full Azure Resource ID of the Sentinel workspace.
92
+
-`-tableName` : Name of the existing table to copy schema from (not required when using `-SchemaFile`).
68
93
-`-newTableName` : Name for the new table.
69
94
-`-type` : Table type (`analytics`, `datalake`/`dl`, `auxiliary`/`aux`, `basic`).
70
95
-`-retention` : Interactive/analytics retention in days.
71
96
-`-totalRetention` : Total retention in days.
72
97
-`-ConvertToString` : (Optional) Convert dynamic columns to string (recommended for Data Lake and Auxiliary tables).
73
-
-`-tenantId` : (Optional) Azure tenant ID for authentication.
98
+
-`-SchemaFile` : (Optional) Path to JSON schema file for Bring Your Own Schema (BYOS) functionality.
99
+
-`-TenantId` : (Optional) Azure tenant ID for authentication.
74
100
75
101
## Notes
76
102
77
103
- The script uses KQL `getschema` to retrieve table schemas. Columns of type `guid` are reported as `string` due to unknown reason. If the table you're creating a copy has guid type column(s) it causes a mismatch with column types when creating DCR. Workaround is to modify DCR with transformKql:
Copy file name to clipboardExpand all lines: Tools/TableCreator/tableCreator.ps1
+93-39Lines changed: 93 additions & 39 deletions
Original file line number
Diff line number
Diff line change
@@ -1,16 +1,17 @@
1
1
<#
2
2
.SYNOPSIS
3
-
Creates a new Sentinel table with the same schema as an existing table.
3
+
Creates a new Sentinel table with the same schema as an existing table, or BYOS (bring-your-own-schema).
4
4
5
5
.DESCRIPTION
6
6
This script queries the schema of an existing Sentinel table and creates a new table with the same schema.
7
+
Alternatively, you can provide a JSON schema file (bring-your-own-schema).
7
8
It supports Analytics, Auxiliary/Data Lake, and Basic table types, and allows for retention settings and conversion of dynamic columns to string for Auxiliary/Data Lake tables.
8
9
The script prompts for any missing parameters and can be run interactively or with command-line arguments.
9
10
10
11
.PARAMETERFullResourceId
11
12
The full resource ID of the Sentinel/Log Analytics Workspace. If not provided, you will be prompted.
12
13
Resource ID can be found in Log Analytics Workspace > JSON View > Copy button.
13
-
To hardcode the Resource ID for your environment, edit the $resourceId variable in the script (line 70).
14
+
To hardcode the Resource ID for your environment, edit the $resourceId variable in the script (line 78).
14
15
15
16
.PARAMETERtableName
16
17
The name of the existing table to copy the schema from (e.g., SecurityEvent).
@@ -32,27 +33,34 @@
32
33
For Auxiliary/Data Lake tables, converts dynamic columns to string.
33
34
PRO TIP: If the copied table has dynamic columns, you may create it initially as Analytics, and then change to Data Lake later. This will preserve the dynamic types.
34
35
35
-
.PARAMETERtenantId
36
+
.PARAMETERTenantId
36
37
Azure tenant ID. Required only if not running in Azure Cloud Shell.
37
38
Requires the Az PowerShell module installed.
38
39
40
+
.PARAMETERSchemaFile
41
+
Path to a JSON schema file (bring-your-own-schema). If provided, the schema will be read from this file instead of querying an existing table.
[string]$SchemaFile,# New: path to a JSON schema file (bring-your-own-schema)
56
64
[ValidateScript({
57
65
if ($_-match'^/subscriptions/[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}/resourcegroups/[a-zA-Z0-9-_]+/providers/microsoft.operationalinsights/workspaces/[a-zA-Z0-9-_]+$') {
0 commit comments