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