From 90efce488f66d1d3e325622f6863ddf7b4316371 Mon Sep 17 00:00:00 2001 From: "Bobby Abellana (aider)" Date: Wed, 19 Feb 2025 14:01:17 -0800 Subject: [PATCH] feat: Add Install-Dependencies.ps1 for SharePoint XLS Converter setup --- Install-Dependencies.ps1 | 50 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 Install-Dependencies.ps1 diff --git a/Install-Dependencies.ps1 b/Install-Dependencies.ps1 new file mode 100644 index 0000000..eee73d6 --- /dev/null +++ b/Install-Dependencies.ps1 @@ -0,0 +1,50 @@ +#Requires -RunAsAdministrator +<# +.SYNOPSIS +Installs prerequisites for SharePoint XLS Converter application +#> + +# Enable TLS 1.2 for secure connections +[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 + +Write-Host "Installing required modules..." -ForegroundColor Cyan + +# Install PnP.PowerShell module if not exists +if (-not (Get-Module -ListAvailable -Name PnP.PowerShell)) { + try { + Install-Module PnP.PowerShell -Scope CurrentUser -Force -AllowClobber + Write-Host "PnP.PowerShell module installed successfully" -ForegroundColor Green + } + catch { + Write-Host "Failed to install PnP.PowerShell: $_" -ForegroundColor Red + exit 1 + } +} +else { + Write-Host "PnP.PowerShell module is already installed" -ForegroundColor Yellow +} + +# Check for Excel installation +try { + $excelCheck = New-Object -ComObject Excel.Application -ErrorAction Stop + $excelCheck.Quit() + [System.Runtime.Interopservices.Marshal]::ReleaseComObject($excelCheck) | Out-Null + Write-Host "Microsoft Excel is installed" -ForegroundColor Green +} +catch { + Write-Host @" + Microsoft Excel not found! The conversion feature requires: + 1. Microsoft Excel 2013 or newer + 2. PowerShell must run in STA mode + Run the main script like this: + powershell.exe -STA -File .\MainForm.ps1 +"@ -ForegroundColor Red + exit 1 +} + +Write-Host @" +Installation complete! Run the main application with: +powershell.exe -STA -File .\MainForm.ps1 + +Note: First run might take longer while modules load +"@ -ForegroundColor Green