From d18f8dad970d2a96634df36952337a7e1a00a1fe Mon Sep 17 00:00:00 2001 From: dyoder Date: Sun, 9 Aug 2020 19:09:24 -0400 Subject: [PATCH] update --- Deploy-PSModule.ps1 | 15 ++++++++++++--- PSModule/PSModule.psm1 | 2 +- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/Deploy-PSModule.ps1 b/Deploy-PSModule.ps1 index c49aabb..bfbb245 100644 --- a/Deploy-PSModule.ps1 +++ b/Deploy-PSModule.ps1 @@ -5,14 +5,19 @@ $MSPName = "Emberkom" $ModuleName = "PSModule" ## Define base URL for downloading module file -$ModuleURL = "https://dev.emberkom.com/emberkom/management-scripts/raw/branch/master/${ModuleName}.psm1" +$ModuleURL = "https://dev.emberkom.com/emberkom/management-scripts/raw/branch/master/${ModuleName}/${ModuleName}.psm1" ## Setup the MSP management directories If ( Test-Path ${Env:ProgramData} ) { $RootDir = "${Env:ProgramData}\${MSPName}" } Else { $RootDir = "${Env:SystemDrive}\${MSPName}" } -## Set the path to this module +## Set the path to this module and make the directory for it $ModulePath = "${RootDir}\Scripts\${ModuleName}" +If ( !(Test-Path $ModulePath) ) +{ + Try { New-Item -Path $ModulePath -ItemType Directory -Force | Out-Null } + Catch { Write-Output $_.Exception.Message } +} ## Make sure all the management directories exist If ( !(Test-Path $RootDir) ) @@ -41,4 +46,8 @@ If ( !(Test-Path "${RootDir}\Logs") ) ## Download the module file Try { (New-Object Net.WebClient).DownloadFile($ModuleURL, "${RootDir}\Scripts\${ModuleName}\${ModuleName}.psm1") } -Catch { Write-Output $_.Exception.Message } \ No newline at end of file +Catch { Write-Output $_.Exception.Message } + +## Import the new module to test +If ( Test-Path "${RootDir}\Scripts\${ModuleName}\${ModuleName}.psm1" ) +{ Import-Module -Name "${RootDir}\Scripts\${ModuleName}\${ModuleName}.psm1" } \ No newline at end of file diff --git a/PSModule/PSModule.psm1 b/PSModule/PSModule.psm1 index 138b31c..3b918ed 100644 --- a/PSModule/PSModule.psm1 +++ b/PSModule/PSModule.psm1 @@ -66,7 +66,7 @@ Function IsDownloadable Catch [System.Net.WebException] { $HTTPResponse = $_.Exception.Response } ## Close the connection, because we're done with it - Finaly { $HTTPResponse.Close() } + Finally { $HTTPResponse.Close() } ## Test to make sure we received a status of 200 "OK" from the resource If ($HTTPStatus -eq 200) { Return $true }