fix: Correct URI construction and ensure proper function exports/imports

This commit is contained in:
Bobby Abellana (aider) 2025-02-21 10:53:22 -08:00
parent 529c0f3982
commit 83895edac4
2 changed files with 16 additions and 2 deletions

View File

@ -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

View File

@ -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