44 lines
1.6 KiB
PowerShell
44 lines
1.6 KiB
PowerShell
## 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
|
||
|
|
$ModuleURL = "https://dev.emberkom.com/emberkom/management-scripts/raw/branch/master/${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
|
||
|
|
$ModulePath = "${RootDir}\Scripts\${ModuleName}"
|
||
|
|
|
||
|
|
## Make sure all the management directories exist
|
||
|
|
If ( !(Test-Path $RootDir) )
|
||
|
|
{
|
||
|
|
Try { New-Item -Path $RootDir -ItemType Directory -Force | Out-Null }
|
||
|
|
Catch { Write-Output $_.Exception.Message }
|
||
|
|
}
|
||
|
|
If ( !(Test-Path "${RootDir}\Scripts") )
|
||
|
|
{
|
||
|
|
Try { New-Item -Path "${RootDir}\Scripts" -ItemType Directory -Force | Out-Null }
|
||
|
|
Catch { Write-Output $_.Exception.Message }
|
||
|
|
}
|
||
|
|
If ( !(Test-Path "${RootDir}\Tools") )
|
||
|
|
{
|
||
|
|
Try { New-Item -Path "${RootDir}\Tools" -ItemType Directory -Force | Out-Null }
|
||
|
|
Catch { Write-Output $_.Exception.Message }
|
||
|
|
}
|
||
|
|
If ( !(Test-Path "${RootDir}\Logs") )
|
||
|
|
{
|
||
|
|
Try { New-Item -Path "${RootDir}\Logs" -ItemType Directory -Force | Out-Null }
|
||
|
|
Catch { Write-Output $_.Exception.Message }
|
||
|
|
}
|
||
|
|
|
||
|
|
## Create environment variable for the root MSP directory
|
||
|
|
[System.Environment]::SetEnvironmentVariable('MSPDir',"${RootDir}",[System.EnvironmentVariableTarget]::Machine)
|
||
|
|
|
||
|
|
## Download the module file
|
||
|
|
Try { (New-Object Net.WebClient).DownloadFile($ModuleURL, "${RootDir}\Scripts\${ModuleName}\${ModuleName}.psm1") }
|
||
|
|
Catch { Write-Output $_.Exception.Message }
|