-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathIntuneStack.psm1
More file actions
68 lines (54 loc) · 1.93 KB
/
Copy pathIntuneStack.psm1
File metadata and controls
68 lines (54 loc) · 1.93 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
$gitResults = New-TemporaryFile
$Process = @{
FilePath = 'git'
WorkingDirectory = $PSScriptRoot
RedirectStandardOutput = $gitResults
Wait = $true
NoNewWindow = $true
}
Start-Process @Process -ArgumentList 'branch --show-current'
$content = Get-Content -LiteralPath $gitResults -Raw
if ($content.Trim() -ne 'main') {
Start-Process @Process -ArgumentList 'checkout main'
}
Start-Process @Process -ArgumentList 'fetch'
Start-Process @Process -ArgumentList 'diff main origin/main --compact-summary'
$content = Get-Content -LiteralPath $gitResults -Raw
if ($content) {
Write-Host "IntuneStack update detected — downloading latest version..."
Start-Process @Process -ArgumentList 'reset --hard origin/main'
$content = Get-Content -LiteralPath $gitResults
Write-Host $content
Write-Host "Reload your PowerShell session to apply the update."
}
if (Test-Path $gitResults) {
Remove-Item -Path $gitResults -Force
}
# Import public functions
$Path = Join-Path $PSScriptRoot 'Public'
$Functions = Get-ChildItem -Path $Path -Filter '*.ps1'
foreach ($import in $Functions) {
try {
Write-Verbose "dot-sourcing file '$($import.fullname)'"
. $import.fullname
} catch {
Write-Error -Message "Failed to import function $($import.name)"
}
}
# Validate required modules
[System.Collections.Generic.List[PSObject]]$RequiredModules = @()
$RequiredModules.Add([PSCustomObject]@{
Name = 'Microsoft.Graph.Authentication'
Version = '1.1.5'
})
foreach ($module in $RequiredModules) {
$Check = Get-Module $module.Name -ListAvailable
if (-not $Check) {
throw "Module $($module.Name) not found"
}
$VersionCheck = $Check | Where-Object { $_.Version -ge $module.Version }
if (-not $VersionCheck) {
Write-Error "Module $($module.Name) running older version"
}
Import-Module -Name $module.Name
}