update
This commit is contained in:
+11
-2
@@ -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) )
|
||||
@@ -42,3 +47,7 @@ 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 }
|
||||
|
||||
## Import the new module to test
|
||||
If ( Test-Path "${RootDir}\Scripts\${ModuleName}\${ModuleName}.psm1" )
|
||||
{ Import-Module -Name "${RootDir}\Scripts\${ModuleName}\${ModuleName}.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 }
|
||||
|
||||
Reference in New Issue
Block a user