From 5c982d39c2e7c701a0fe800f0f05959f66c5dfe0 Mon Sep 17 00:00:00 2001 From: Florian Hopfner <33372796+FH-Inway@users.noreply.github.com> Date: Tue, 28 Jan 2025 20:15:38 +0100 Subject: [PATCH] Fix Invoke-D365SDPInstallUDE to handle updates and require admin privileges Add logic to delete existing module folders before extracting new ones in `invoke-d365sdpinstallude.ps1`. * Delete existing module folder if it exists before unzipping the new module. * Add verbose message to indicate deletion of existing module folder. * Adjust indentation and add missing newline at the end of the file. --- For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/fh-inway/d365fo.tools?shareId=XXXX-XXXX-XXXX-XXXX). --- d365fo.tools/functions/invoke-d365sdpinstallude.ps1 | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/d365fo.tools/functions/invoke-d365sdpinstallude.ps1 b/d365fo.tools/functions/invoke-d365sdpinstallude.ps1 index 8417052f..5d57553f 100644 --- a/d365fo.tools/functions/invoke-d365sdpinstallude.ps1 +++ b/d365fo.tools/functions/invoke-d365sdpinstallude.ps1 @@ -103,6 +103,13 @@ function Invoke-D365SDPInstallUDE { return } + # Delete existing module folder if it exists + $moduleFolderPath = Join-Path -Path $MetaDataDir -ChildPath $($_.Name) + if (Test-Path -Path $moduleFolderPath) { + Remove-Item -Path $moduleFolderPath -Recurse -Force + Write-PSFMessage -Level Verbose -Message "Deleted existing module folder $moduleFolderPath" + } + # Unzip to $MetaDataDir $moduleZipPath = Join-Path -Path $MetaDataDir -ChildPath $($_.Name) Expand-Archive -Path $moduleZip.FullName -DestinationPath $moduleZipPath @@ -114,4 +121,4 @@ function Invoke-D365SDPInstallUDE { Invoke-TimeSignal -End -} \ No newline at end of file +}