-
-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathIntuneHydrationKit.psm1
More file actions
106 lines (95 loc) · 3.3 KB
/
IntuneHydrationKit.psm1
File metadata and controls
106 lines (95 loc) · 3.3 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#Requires -Version 7.0
<#
.SYNOPSIS
Root module for IntuneHydrationKit
.DESCRIPTION
Hydrates Microsoft Intune tenants with best-practice baseline configurations.
#>
# Module-level variables
$script:ModuleRoot = $PSScriptRoot
$script:TemplatesPath = Join-Path -Path $script:ModuleRoot -ChildPath 'Templates'
$script:HydrationState = @{
Connected = $false
TenantId = $null
}
# Module-level state for logging
$script:LogPath = $null
$script:VerboseLogging = $false
$script:CurrentLogFile = $null
# Module-level state for Graph environment
$script:GraphEnvironment = $null
$script:GraphEndpoint = $null
# Graph API batch operation settings
$script:MaxBatchSize = 10 # Graph API batch limit (max 20, using 10 for safety)
# Prefix prepended to every imported resource's displayName/name for easy identification
$script:ImportPrefix = '[IHD] '
# Hydration kit marker embedded in descriptions/notes to identify objects created by this kit
$script:HydrationMarker = 'Imported by Intune Hydration Kit'
$script:HydrationMarkerAlt = 'Imported by Intune-Hydration-Kit'
# Import private functions
$privatePath = Join-Path -Path $script:ModuleRoot -ChildPath 'Private'
if (Test-Path -Path $privatePath) {
$privateFiles = Get-ChildItem -Path $privatePath -Filter '*.ps1' -File
foreach ($file in $privateFiles) {
try {
. $file.FullName
Write-Verbose "Imported private function: $($file.BaseName)"
} catch {
throw [System.Exception]::new(
"Failed to import private function '$($file.FullName)': $($_.Exception.Message)",
$_.Exception
)
}
}
}
# Import public functions
$publicPath = Join-Path -Path $script:ModuleRoot -ChildPath 'Public'
if (Test-Path -Path $publicPath) {
$publicFiles = Get-ChildItem -Path $publicPath -Filter '*.ps1' -File
foreach ($file in $publicFiles) {
try {
. $file.FullName
Write-Verbose "Imported public function: $($file.BaseName)"
} catch {
throw [System.Exception]::new(
"Failed to import public function '$($file.FullName)': $($_.Exception.Message)",
$_.Exception
)
}
}
}
# Define public functions to export (must match FunctionsToExport in .psd1)
$publicFunctions = @(
# Main entry point
'Invoke-IntuneHydration',
# Core hydration functions
'Connect-IntuneHydration',
'Test-IntunePrerequisites',
# Import functions
'New-IntuneDynamicGroup',
'New-IntuneStaticGroup',
'Get-OpenIntuneBaseline',
'Import-IntuneBaseline',
'Import-CISBaseline',
'Import-IntuneCompliancePolicy',
'Import-IntuneAppProtectionPolicy',
'Import-IntuneNotificationTemplate',
'Import-IntuneEnrollmentProfile',
'Import-IntuneDeviceFilter',
'Import-IntuneConditionalAccessPolicy',
'Import-IntuneMobileApp',
# Helper functions
'Initialize-HydrationLogging',
'Write-HydrationLog',
'Import-HydrationSettings',
# Result helpers (used by orchestrator)
'New-HydrationResult',
'Get-ResultSummary',
'Get-GraphErrorMessage',
# Safety helpers (used by orchestrator for deletion safety checks)
'Test-HydrationKitObject',
# Utility helpers
'Get-ObfuscatedTenantId'
)
# Export functions
Export-ModuleMember -Function $publicFunctions