2020-08-09 18:45:08 -04:00
|
|
|
## Set the MSP name and environment variable
|
|
|
|
|
$MSPName = "Emberkom"
|
|
|
|
|
|
|
|
|
|
## Set the name of the module to deploy
|
|
|
|
|
$ModuleName = "PSModule"
|
|
|
|
|
|
|
|
|
|
## Define base URL for downloading module file
|
2020-08-09 19:09:24 -04:00
|
|
|
$ModuleURL = "https://dev.emberkom.com/emberkom/management-scripts/raw/branch/master/${ModuleName}/${ModuleName}.psm1"
|
2020-08-09 18:45:08 -04:00
|
|
|
|
|
|
|
|
## Setup the MSP management directories
|
|
|
|
|
If ( Test-Path ${Env:ProgramData} )
|
2020-08-18 16:20:20 -04:00
|
|
|
{ $MSPRoot = "${Env:ProgramData}\${MSPName}" } Else { $MSPRoot = "${Env:SystemDrive}\${MSPName}" }
|
|
|
|
|
$MSPScripts = "${MSPRoot}\Scripts"
|
|
|
|
|
$MSPTools = "${MSPRoot}\Tools"
|
|
|
|
|
$MSPLogs = "${MSPRoot}\Logs"
|
2020-08-09 18:45:08 -04:00
|
|
|
|
2020-08-09 19:09:24 -04:00
|
|
|
## Set the path to this module and make the directory for it
|
2020-08-18 16:20:20 -04:00
|
|
|
$ModulePath = "${MSPRoot}\Scripts\${ModuleName}"
|
2020-08-14 14:19:37 -04:00
|
|
|
|
|
|
|
|
## Create the path to the module
|
2020-08-09 19:09:24 -04:00
|
|
|
If ( !(Test-Path $ModulePath) )
|
|
|
|
|
{
|
|
|
|
|
Try { New-Item -Path $ModulePath -ItemType Directory -Force | Out-Null }
|
|
|
|
|
Catch { Write-Output $_.Exception.Message }
|
|
|
|
|
}
|
2020-08-09 18:45:08 -04:00
|
|
|
|
2020-08-14 14:19:37 -04:00
|
|
|
## Set the environment variable to the module
|
2020-08-18 16:20:20 -04:00
|
|
|
[System.Environment]::SetEnvironmentVariable('MSPPSModule',"${MSPRoot}\Scripts\${ModuleName}",[System.EnvironmentVariableTarget]::Machine)
|
2020-08-14 14:19:37 -04:00
|
|
|
|
2020-08-09 18:45:08 -04:00
|
|
|
## Make sure all the management directories exist
|
2020-08-18 16:20:20 -04:00
|
|
|
If ( !(Test-Path $MSPRoot) )
|
2020-08-09 18:45:08 -04:00
|
|
|
{
|
2020-08-18 16:20:20 -04:00
|
|
|
Try { New-Item -Path $MSPRoot -ItemType Directory -Force | Out-Null }
|
2020-08-09 18:45:08 -04:00
|
|
|
Catch { Write-Output $_.Exception.Message }
|
|
|
|
|
}
|
2020-08-18 16:20:20 -04:00
|
|
|
If ( !(Test-Path $MSPScripts) )
|
2020-08-09 18:45:08 -04:00
|
|
|
{
|
2020-08-18 16:20:20 -04:00
|
|
|
Try { New-Item -Path $MSPScripts -ItemType Directory -Force | Out-Null }
|
2020-08-09 18:45:08 -04:00
|
|
|
Catch { Write-Output $_.Exception.Message }
|
|
|
|
|
}
|
2020-08-18 16:20:20 -04:00
|
|
|
If ( !(Test-Path $MSPTools) )
|
2020-08-09 18:45:08 -04:00
|
|
|
{
|
2020-08-18 16:20:20 -04:00
|
|
|
Try { New-Item -Path $MSPTools -ItemType Directory -Force | Out-Null }
|
2020-08-09 18:45:08 -04:00
|
|
|
Catch { Write-Output $_.Exception.Message }
|
|
|
|
|
}
|
2020-08-18 16:20:20 -04:00
|
|
|
If ( !(Test-Path $MSPLogs) )
|
2020-08-09 18:45:08 -04:00
|
|
|
{
|
2020-08-18 16:20:20 -04:00
|
|
|
Try { New-Item -Path $MSPLogs -ItemType Directory -Force | Out-Null }
|
2020-08-09 18:45:08 -04:00
|
|
|
Catch { Write-Output $_.Exception.Message }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
## Create environment variable for the root MSP directory
|
2020-08-18 16:20:20 -04:00
|
|
|
[System.Environment]::SetEnvironmentVariable('MSPDir',"${MSPRoot}",[System.EnvironmentVariableTarget]::Machine)
|
2020-08-09 18:45:08 -04:00
|
|
|
|
|
|
|
|
## Download the module file
|
2020-08-18 16:20:20 -04:00
|
|
|
Try { (New-Object Net.WebClient).DownloadFile($ModuleURL, "${MSPRoot}\Scripts\${ModuleName}\${ModuleName}.psm1") }
|
2020-08-09 19:09:24 -04:00
|
|
|
Catch { Write-Output $_.Exception.Message }
|