|
181 | 181 | throw $_ |
182 | 182 | } |
183 | 183 |
|
184 | | - if ($Pillar -in ('All', 'Identity')) { |
| 184 | + # --------------------------------------------------------------------------- |
| 185 | + # Resolve which table groups are needed. Each table is imported at most once. |
| 186 | + # --------------------------------------------------------------------------- |
| 187 | + |
| 188 | + # Identity and Network need User; AI does not. |
| 189 | + $needsUser = $Pillar -in ('All', 'Identity', 'Network') |
| 190 | + |
| 191 | + # All pillars except Devices need Application and ServicePrincipal. |
| 192 | + $needsApplicationAndServicePrincipal = $Pillar -in ('All', 'Identity', 'Network', 'AI') |
| 193 | + |
| 194 | + # AI-specific derived-type tables that carry sponsor relationships inline. |
| 195 | + $needsAgentIdentity = $Pillar -in ('All', 'AI') |
| 196 | + |
| 197 | + # Identity and AI need SignIn; Network does not. |
| 198 | + $needsSignIn = $Pillar -in ('All', 'Identity', 'AI') |
| 199 | + |
| 200 | + # All pillars except Devices share the Role table family. |
| 201 | + $needsRoles = $Pillar -in ('All', 'Identity', 'Network', 'AI') |
| 202 | + |
| 203 | + # Tables exclusive to the Identity pillar. |
| 204 | + $needsIdentityExtras = $Pillar -in ('All', 'Identity') |
| 205 | + |
| 206 | + # Tables exclusive to the Devices pillar. |
| 207 | + $needsDevices = $Pillar -in ('All', 'Devices') |
| 208 | + |
| 209 | + # --------------------------------------------------------------------------- |
| 210 | + # Import tables — each table loaded exactly once. |
| 211 | + # --------------------------------------------------------------------------- |
| 212 | + |
| 213 | + if ($needsUser) { |
185 | 214 | Import-EntraTableLogged -Database $database -ExportPath $ExportPath -TableName 'User' -LogsPath $LogsPath |
| 215 | + } |
| 216 | + |
| 217 | + if ($needsApplicationAndServicePrincipal) { |
186 | 218 | Import-EntraTableLogged -Database $database -ExportPath $ExportPath -TableName 'Application' -LogsPath $LogsPath |
187 | 219 | Import-EntraTableLogged -Database $database -ExportPath $ExportPath -TableName 'ServicePrincipal' -LogsPath $LogsPath |
188 | | - Import-EntraTableLogged -Database $database -ExportPath $ExportPath -TableName 'ServicePrincipalSignIn' -LogsPath $LogsPath |
| 220 | + } |
| 221 | + |
| 222 | + if ($needsAgentIdentity) { |
| 223 | + Import-EntraTableLogged -Database $database -ExportPath $ExportPath -TableName 'AgentIdentityBlueprint' -LogsPath $LogsPath |
| 224 | + Import-EntraTableLogged -Database $database -ExportPath $ExportPath -TableName 'AgentIdentity' -LogsPath $LogsPath |
| 225 | + Import-EntraTableLogged -Database $database -ExportPath $ExportPath -TableName 'AgentIdentityBlueprintPrincipal' -LogsPath $LogsPath |
| 226 | + } |
| 227 | + |
| 228 | + if ($needsSignIn) { |
189 | 229 | Import-EntraTableLogged -Database $database -ExportPath $ExportPath -TableName 'SignIn' -LogsPath $LogsPath |
| 230 | + } |
| 231 | + |
| 232 | + if ($needsRoles) { |
190 | 233 | Import-EntraTableLogged -Database $database -ExportPath $ExportPath -TableName 'RoleDefinition' -LogsPath $LogsPath |
191 | 234 | Import-EntraTableLogged -Database $database -ExportPath $ExportPath -TableName 'RoleAssignment' -LogsPath $LogsPath |
192 | 235 | Import-EntraTableLogged -Database $database -ExportPath $ExportPath -TableName 'RoleAssignmentGroup' -LogsPath $LogsPath |
193 | 236 | Import-EntraTableLogged -Database $database -ExportPath $ExportPath -TableName 'RoleAssignmentScheduleInstance' -LogsPath $LogsPath |
194 | 237 | Import-EntraTableLogged -Database $database -ExportPath $ExportPath -TableName 'RoleAssignmentScheduleInstanceGroup' -LogsPath $LogsPath |
195 | 238 | Import-EntraTableLogged -Database $database -ExportPath $ExportPath -TableName 'RoleEligibilityScheduleInstance' -LogsPath $LogsPath |
196 | 239 | Import-EntraTableLogged -Database $database -ExportPath $ExportPath -TableName 'RoleEligibilityScheduleInstanceGroup' -LogsPath $LogsPath |
| 240 | + } |
| 241 | + |
| 242 | + if ($needsIdentityExtras) { |
| 243 | + Import-EntraTableLogged -Database $database -ExportPath $ExportPath -TableName 'ServicePrincipalSignIn' -LogsPath $LogsPath |
197 | 244 | Import-EntraTableLogged -Database $database -ExportPath $ExportPath -TableName 'RoleManagementPolicyAssignment' -LogsPath $LogsPath |
198 | 245 | Import-EntraTableLogged -Database $database -ExportPath $ExportPath -TableName 'UserRegistrationDetails' -LogsPath $LogsPath |
199 | 246 | } |
200 | 247 |
|
201 | | - if ($Pillar -in ('All', 'Devices')) { |
| 248 | + if ($needsDevices) { |
202 | 249 | Import-EntraTableLogged -Database $database -ExportPath $ExportPath -TableName 'Device' -LogsPath $LogsPath |
203 | 250 | Import-EntraTableLogged -Database $database -ExportPath $ExportPath -TableName 'ConfigurationPolicy' -LogsPath $LogsPath |
204 | 251 | } |
205 | 252 |
|
206 | | - if ($Pillar -in ('All', 'Network')) { |
207 | | - Import-EntraTableLogged -Database $database -ExportPath $ExportPath -TableName 'User' -LogsPath $LogsPath |
208 | | - Import-EntraTableLogged -Database $database -ExportPath $ExportPath -TableName 'Application' -LogsPath $LogsPath |
209 | | - Import-EntraTableLogged -Database $database -ExportPath $ExportPath -TableName 'ServicePrincipal' -LogsPath $LogsPath |
210 | | - Import-EntraTableLogged -Database $database -ExportPath $ExportPath -TableName 'RoleDefinition' -LogsPath $LogsPath |
211 | | - Import-EntraTableLogged -Database $database -ExportPath $ExportPath -TableName 'RoleAssignment' -LogsPath $LogsPath |
212 | | - Import-EntraTableLogged -Database $database -ExportPath $ExportPath -TableName 'RoleAssignmentGroup' -LogsPath $LogsPath |
213 | | - Import-EntraTableLogged -Database $database -ExportPath $ExportPath -TableName 'RoleAssignmentScheduleInstance' -LogsPath $LogsPath |
214 | | - Import-EntraTableLogged -Database $database -ExportPath $ExportPath -TableName 'RoleAssignmentScheduleInstanceGroup' -LogsPath $LogsPath |
215 | | - Import-EntraTableLogged -Database $database -ExportPath $ExportPath -TableName 'RoleEligibilityScheduleInstance' -LogsPath $LogsPath |
216 | | - Import-EntraTableLogged -Database $database -ExportPath $ExportPath -TableName 'RoleEligibilityScheduleInstanceGroup' -LogsPath $LogsPath |
217 | | - } |
218 | | - |
219 | | - if ($Pillar -in ('All', 'AI')) { |
220 | | - Import-EntraTableLogged -Database $database -ExportPath $ExportPath -TableName 'Application' -LogsPath $LogsPath |
221 | | - Import-EntraTableLogged -Database $database -ExportPath $ExportPath -TableName 'ServicePrincipal' -LogsPath $LogsPath |
222 | | - Import-EntraTableLogged -Database $database -ExportPath $ExportPath -TableName 'SignIn' -LogsPath $LogsPath |
223 | | - Import-EntraTableLogged -Database $database -ExportPath $ExportPath -TableName 'RoleDefinition' -LogsPath $LogsPath |
224 | | - Import-EntraTableLogged -Database $database -ExportPath $ExportPath -TableName 'RoleAssignment' -LogsPath $LogsPath |
225 | | - Import-EntraTableLogged -Database $database -ExportPath $ExportPath -TableName 'RoleAssignmentGroup' -LogsPath $LogsPath |
226 | | - Import-EntraTableLogged -Database $database -ExportPath $ExportPath -TableName 'RoleAssignmentScheduleInstance' -LogsPath $LogsPath |
227 | | - Import-EntraTableLogged -Database $database -ExportPath $ExportPath -TableName 'RoleAssignmentScheduleInstanceGroup' -LogsPath $LogsPath |
228 | | - Import-EntraTableLogged -Database $database -ExportPath $ExportPath -TableName 'RoleEligibilityScheduleInstance' -LogsPath $LogsPath |
229 | | - Import-EntraTableLogged -Database $database -ExportPath $ExportPath -TableName 'RoleEligibilityScheduleInstanceGroup' -LogsPath $LogsPath |
230 | | - } |
231 | | - |
232 | | - if ($Pillar -in ('All', 'Identity', 'Network', 'AI')) { |
| 253 | + if ($needsRoles) { |
233 | 254 | New-ViewRole -Database $database |
234 | 255 | } |
235 | 256 |
|
|
0 commit comments