From cb075aa035d7e5a17b63f42f27d5c792491cbb48 Mon Sep 17 00:00:00 2001 From: Ben Potter Date: Wed, 26 Jun 2024 16:44:21 -0500 Subject: [PATCH] fix order --- windows-rdp/main.tf | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/windows-rdp/main.tf b/windows-rdp/main.tf index ac3b902..813e164 100644 --- a/windows-rdp/main.tf +++ b/windows-rdp/main.tf @@ -60,12 +60,13 @@ resource "coder_script" "windows-rdp" { $moduleName = "DevolutionsGateway" $moduleVersion = "2024.1.5" + Install-Module -Name $moduleName -RequiredVersion $moduleVersion -Force -Confirm:$false -SkipPublisherCheck + try { # Try to import the module directly Import-Module $moduleName -ErrorAction Stop } catch { # If it fails, install and then import the module - Install-Module -Name $moduleName -RequiredVersion $moduleVersion -Force -Confirm:$false -SkipPublisherCheck # Construct the module path for system-wide installation $moduleBasePath = "C:\Windows\system32\config\systemprofile\Documents\PowerShell\Modules\$moduleName\$moduleVersion"