## 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}/${ModuleName}.psm1" ## Setup the MSP management directories If ( Test-Path ${Env:ProgramData} ) { $MSPRoot = "${Env:ProgramData}\${MSPName}" } Else { $MSPRoot = "${Env:SystemDrive}\${MSPName}" } $MSPScripts = "${MSPRoot}\Scripts" $MSPTools = "${MSPRoot}\Tools" $MSPLogs = "${MSPRoot}\Logs" ## Set the path to this module and make the directory for it $ModulePath = "${MSPRoot}\Scripts\${ModuleName}" ## Create the path to the module If ( !(Test-Path $ModulePath) ) { Try { New-Item -Path $ModulePath -ItemType Directory -Force | Out-Null } Catch { Write-Output $_.Exception.Message } } ## Set the environment variable to the module [System.Environment]::SetEnvironmentVariable('MSPPSModule',"${MSPRoot}\Scripts\${ModuleName}",[System.EnvironmentVariableTarget]::Machine) ## Make sure all the management directories exist If ( !(Test-Path $MSPRoot) ) { Try { New-Item -Path $MSPRoot -ItemType Directory -Force | Out-Null } Catch { Write-Output $_.Exception.Message } } If ( !(Test-Path $MSPScripts) ) { Try { New-Item -Path $MSPScripts -ItemType Directory -Force | Out-Null } Catch { Write-Output $_.Exception.Message } } If ( !(Test-Path $MSPTools) ) { Try { New-Item -Path $MSPTools -ItemType Directory -Force | Out-Null } Catch { Write-Output $_.Exception.Message } } If ( !(Test-Path $MSPLogs) ) { Try { New-Item -Path $MSPLogs -ItemType Directory -Force | Out-Null } Catch { Write-Output $_.Exception.Message } } ## Create environment variable for the root MSP directory [System.Environment]::SetEnvironmentVariable('MSPDir',"${MSPRoot}",[System.EnvironmentVariableTarget]::Machine) ## Download the module file Try { (New-Object Net.WebClient).DownloadFile($ModuleURL, "${MSPRoot}\Scripts\${ModuleName}\${ModuleName}.psm1") } Catch { Write-Output $_.Exception.Message }