-
Notifications
You must be signed in to change notification settings - Fork 234
Expand file tree
/
Copy pathMaester.psm1
More file actions
63 lines (55 loc) · 2.22 KB
/
Maester.psm1
File metadata and controls
63 lines (55 loc) · 2.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<#
.DISCLAIMER
THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
PARTICULAR PURPOSE.
Copyright (c) Microsoft Corporation. All rights reserved.
#>
## Initialize Module Configuration
#Requires -Modules Pester, Microsoft.Graph.Authentication
## Initialize Module Variables
## Update Clear-ModuleVariable function in internal/Clear-ModuleVariable.ps1 if you add new variables here
$__MtSession = @{
GraphCache = @{}
GraphBaseUri = $null
TestResultDetail = @{}
Connections = @()
DnsCache = @()
ExoCache = @{}
OrcaCache = @{}
SpoCache = @{}
AIAgentInfo = $null
DataverseApiBase = $null # Resolved Dataverse OData API base URL (e.g. https://org123.api.crm.dynamics.com/api/data/v9.2)
DataverseResourceUrl = $null # Dataverse resource URL for token acquisition (e.g. https://org123.crm.dynamics.com)
DataverseEnvironmentId = $null # Environment identifier for display (e.g. org123.crm.dynamics.com)
}
New-Variable -Name __MtSession -Value $__MtSession -Scope Script -Force
# Import private and public scripts and expose the public ones
$privateScripts = @(Get-ChildItem -Path "$PSScriptRoot\internal" -Recurse -Filter "*.ps1" -ErrorAction SilentlyContinue)
$publicScripts = @(Get-ChildItem -Path "$PSScriptRoot\public" -Recurse -Filter "*.ps1" -ErrorAction SilentlyContinue)
$importErrors = @()
foreach ($script in ($privateScripts + $publicScripts)) {
if (-not (Test-Path $script.FullName)) {
$importErrors += "Script file not found: $($script.FullName)"
continue
}
try {
. $script.FullName
} catch {
$errorMessage = "Failed to import function from '$($script.FullName)': $($_.Exception.Message)"
$importErrors += $errorMessage
Write-Warning $errorMessage
}
}
# Report import errors if any occurred
if ($importErrors.Count -gt 0) {
Write-Warning "Module loaded with $($importErrors.Count) import error(s). Some functionality may be unavailable."
}
# Safely import module manifest
try {
$ModuleInfo = Import-PowerShellDataFile -Path "$PsScriptRoot/Maester.psd1" -ErrorAction Stop
} catch {
Write-Warning "Failed to load module manifest: $($_.Exception.Message)"
$ModuleInfo = $null
}