This commit is contained in:
2020-08-09 18:45:08 -04:00
parent 78df7f98c1
commit b0e66c4fa5
3 changed files with 48 additions and 51 deletions
+44
View File
@@ -0,0 +1,44 @@
## 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 }