From 83895edac400cd064b376a7c763d208c4da8c78b Mon Sep 17 00:00:00 2001 From: "Bobby Abellana (aider)" Date: Fri, 21 Feb 2025 10:53:22 -0800 Subject: [PATCH] fix: Correct URI construction and ensure proper function exports/imports --- MainForm.ps1 | 3 ++- SharePointFunctions.ps1 | 15 ++++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/MainForm.ps1 b/MainForm.ps1 index 5fd9a34..033eaef 100644 --- a/MainForm.ps1 +++ b/MainForm.ps1 @@ -5,7 +5,8 @@ Import-Module Microsoft.Graph.Files # Import our components . "$PSScriptRoot\GraphConfig.ps1" -. "$PSScriptRoot\SharePointFunctions.ps1" +$SharePointFunctions = "$PSScriptRoot\SharePointFunctions.ps1" +Import-Module $SharePointFunctions -Force . "$PSScriptRoot\EventHandlers.ps1" # Create main form diff --git a/SharePointFunctions.ps1 b/SharePointFunctions.ps1 index 7ee15ab..ced718a 100644 --- a/SharePointFunctions.ps1 +++ b/SharePointFunctions.ps1 @@ -1,5 +1,18 @@ # SharePointFunctions.ps1 +$script:config = $null # Initialize config variable + +# Export functions that will be called from other scripts +Export-ModuleMember -Function @( + 'Load-Config', + 'Save-Config', + 'Get-FolderBrowser', + 'Connect-SharePoint', + 'List-XlsFiles', + 'Convert-Files', + 'Move-Files' +) + # Load configuration from config.json function Load-Config { try { @@ -441,7 +454,7 @@ function Convert-Files { # Construct the download URI $encodedPath = [System.Web.HttpUtility]::UrlEncode($relativePath).Replace("+", "%20") - $downloadUri = "https://graph.microsoft.com/v1.0/drives/$($drive.Id)/root:/$encodedPath:/content" + $downloadUri = "https://graph.microsoft.com/v1.0/drives/$($drive.Id)/root:/$($encodedPath):/content" # Download the file Invoke-MgGraphRequest -Uri $downloadUri -Method GET -OutFile $downloadPath