Install.ps1
|
<# .SYNOPSIS Installs or updates all dependencies required for AsBuiltReport.Microsoft.Intune. .DESCRIPTION Installs the following modules from the PowerShell Gallery: - AsBuiltReport.Core (report framework) - Microsoft.Graph (Intune / Graph API access) - ImportExcel (Excel workbook export) .NOTES Run this script as an Administrator or with sufficient permissions to install modules. .EXAMPLE .\Install.ps1 .EXAMPLE .\Install.ps1 -Scope CurrentUser #> param( [ValidateSet('AllUsers', 'CurrentUser')] [string]$Scope = 'CurrentUser' ) $RequiredModules = @( @{ Name = 'AsBuiltReport.Core'; MinVersion = '1.4.0' } @{ Name = 'Microsoft.Graph'; MinVersion = '2.0.0' } @{ Name = 'ImportExcel'; MinVersion = '7.0.0' } ) Write-Host "`n AsBuiltReport.Microsoft.Intune — Dependency Installer" -ForegroundColor Cyan Write-Host " ======================================================`n" foreach ($Module in $RequiredModules) { $Installed = Get-Module -ListAvailable -Name $Module.Name -ErrorAction SilentlyContinue | Sort-Object Version -Descending | Select-Object -First 1 if ($Installed -and $Installed.Version -ge [version]$Module.MinVersion) { Write-Host " [OK] $($Module.Name) v$($Installed.Version) is already installed." -ForegroundColor Green } else { Write-Host " [INSTALL] $($Module.Name) (minimum v$($Module.MinVersion))..." -ForegroundColor Yellow try { Install-Module -Name $Module.Name -MinimumVersion $Module.MinVersion ` -Scope $Scope -Repository PSGallery -Force -AllowClobber -ErrorAction Stop Write-Host " [DONE] $($Module.Name) installed successfully." -ForegroundColor Green } catch { Write-Host " [FAIL] $($Module.Name): $($_.Exception.Message)" -ForegroundColor Red } } } Write-Host "`n All dependencies checked. You are ready to run AsBuiltReport.Microsoft.Intune.`n" Write-Host " Example usage:" Write-Host " New-AsBuiltReport -Report Microsoft.Intune -Target 'contoso.onmicrosoft.com' -OutputFolderPath C:\Reports`n" -ForegroundColor Cyan |