feat: Add Microsoft Graph and OpenXml module installation to Install-Dependencies.ps1
This commit is contained in:
parent
03b58af4ea
commit
3859fb5c1f
@ -5,23 +5,51 @@ Installs prerequisites for SharePoint XLS Converter application
|
|||||||
#>
|
#>
|
||||||
|
|
||||||
# Enable TLS 1.2 for secure connections
|
# Enable TLS 1.2 for secure connections
|
||||||
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
|
[Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointProtocolType]::Tls12
|
||||||
|
|
||||||
Write-Host "Installing required modules..." -ForegroundColor Cyan
|
Write-Host "Installing required modules..." -ForegroundColor Cyan
|
||||||
|
|
||||||
# Install PnP.PowerShell module if not exists
|
# Install Microsoft.Graph modules
|
||||||
if (-not (Get-Module -ListAvailable -Name PnP.PowerShell)) {
|
$graphModules = @(
|
||||||
|
"Microsoft.Graph.Sites",
|
||||||
|
"Microsoft.Graph.Files",
|
||||||
|
"Microsoft.Graph.Authentication"
|
||||||
|
)
|
||||||
|
|
||||||
|
foreach ($module in $graphModules) {
|
||||||
|
if (-not (Get-Module -ListAvailable -Name $module)) {
|
||||||
|
try {
|
||||||
|
Install-Module $module -Scope CurrentUser -Force -AllowClobber
|
||||||
|
Write-Host "$module module installed successfully" -ForegroundColor Green
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
Write-Host "Failed to install $module: $_" -ForegroundColor Red
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Write-Host "$module module is already installed" -ForegroundColor Yellow
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Install DocumentFormat.OpenXml module
|
||||||
|
if (-not (Get-Module -ListAvailable -Name DocumentFormat.OpenXml)) {
|
||||||
try {
|
try {
|
||||||
Install-Module PnP.PowerShell -Scope CurrentUser -Force -AllowClobber
|
# Install NuGet package provider if not exists
|
||||||
Write-Host "PnP.PowerShell module installed successfully" -ForegroundColor Green
|
if (-not (Get-PackageProvider -Name NuGet)) {
|
||||||
|
Install-PackageProvider -Name NuGet -Force
|
||||||
|
}
|
||||||
|
Install-Module DocumentFormat.OpenXml -Scope CurrentUser -Force -AllowClobber
|
||||||
|
Write-Host "DocumentFormat.OpenXml module installed successfully" -ForegroundColor Green
|
||||||
}
|
}
|
||||||
catch {
|
catch {
|
||||||
Write-Host "Failed to install PnP.PowerShell: $_" -ForegroundColor Red
|
Write-Host "Failed to install DocumentFormat.OpenXml module: $_" -ForegroundColor Red
|
||||||
exit 1
|
Write-Host "You may need to install the Open XML SDK manually." -ForegroundColor Yellow
|
||||||
|
# Do not exit, as the application might still work if the assembly is in the GAC or a known path
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Write-Host "PnP.PowerShell module is already installed" -ForegroundColor Yellow
|
Write-Host "DocumentFormat.OpenXml module is already installed" -ForegroundColor Yellow
|
||||||
}
|
}
|
||||||
|
|
||||||
# Check for Excel installation
|
# Check for Excel installation
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user