iterate throught directory creation
This commit is contained in:
@@ -9,14 +9,13 @@ $MSPTools = "${MSPRoot}\Tools"
|
||||
$MSPLogs = "${MSPRoot}\Logs"
|
||||
|
||||
## Make sure all the management directories exist
|
||||
If ( !(Test-Path $MSPRoot) )
|
||||
{ New-Item -Path $MSPRoot -ItemType Directory -Force -ErrorAction SilentlyContinue | Out-Null }
|
||||
If ( !(Test-Path $MSPScripts) )
|
||||
{ New-Item -Path $MSPScripts -ItemType Directory -Force -ErrorAction SilentlyContinue | Out-Null }
|
||||
If ( !(Test-Path $MSPTools) )
|
||||
{ New-Item -Path $MSPTools -ItemType Directory -Force -ErrorAction SilentlyContinue | Out-Null }
|
||||
If ( !(Test-Path $MSPLogs) )
|
||||
{ New-Item -Path $MSPLogs -ItemType Directory -Force -ErrorAction SilentlyContinue | Out-Null }
|
||||
$MSPRoot, $MSPScripts, $MSPTools, $MSPLogs | ForEach-Object {
|
||||
If ( !(Test-Path $_) )
|
||||
{
|
||||
Try { New-Item -Path $MSPRoot -ItemType Directory -Force -ErrorAction SilentlyContinue | Out-Null }
|
||||
Catch { Write-Output $_.Exception.Message ; Exit }
|
||||
}
|
||||
}
|
||||
|
||||
## Set a datestamp for any log files that might need to be created
|
||||
$LogFilePrefix = Get-Date -Format "yyyyMMddHHmmss"
|
||||
@@ -149,7 +148,12 @@ If ( $HaltIfRunning )
|
||||
$RunningInstances = Get-Process | Where { $_.Name -like "${name}" }
|
||||
If ( $RunningInstances )
|
||||
{
|
||||
If ( $ForceClose -eq $true ) { $name | Stop-Process -Force ; Log " ""${name}"" (force closed)" -Name $LogName }
|
||||
If ( $ForceClose -eq $true )
|
||||
{
|
||||
Try { $name | Stop-Process -Force }
|
||||
Catch { $_.Exception.Message | Log -Name $LogName ; Exit }
|
||||
Log " ""${name}"" (force closed)" -Name $LogName
|
||||
}
|
||||
Else { $Halt = $true ; Log " ""${name}"" (running)" -Name $LogName }
|
||||
}
|
||||
Else { Log " ""${name}"" (not running)" -Name $LogName }
|
||||
@@ -163,12 +167,12 @@ switch ($PSCmdlet.ParameterSetName)
|
||||
$URL = "https://dev.emberkom.com/emberkom/${Type}/raw/branch/master/${LivePSScript}.ps1"
|
||||
Log "Retrieving : ${LivePSScript}.ps1" -Name $LogName
|
||||
Try { $Script = (New-Object Net.WebClient).DownloadString($URL) }
|
||||
Catch { $_.Exception.Message | Log -Name $LogName }
|
||||
Catch { $_.Exception.Message | Log -Name $LogName ; Exit }
|
||||
Try { $ScriptBlock = [Scriptblock]::Create($Script) }
|
||||
Catch { $_.Exception.Message | Log -Name $LogName }
|
||||
Catch { $_.Exception.Message | Log -Name $LogName ; Exit }
|
||||
Log "Executing: ${LivePSScript}.ps1 ${Arguments}"
|
||||
Try { Invoke-Command -ScriptBlock $ScriptBlock -ArgumentList $Arguments }
|
||||
Catch { $_.Exception.Message | Log -Name $LogName }
|
||||
Catch { $_.Exception.Message | Log -Name $LogName ; Exit }
|
||||
}
|
||||
|
||||
'local'
|
||||
@@ -184,7 +188,7 @@ switch ($PSCmdlet.ParameterSetName)
|
||||
Log " Finished" -Name $LogName
|
||||
}
|
||||
}
|
||||
Catch { $_.Exception.Message | Log -Name $LogName }
|
||||
Catch { $_.Exception.Message | Log -Name $LogName ; Exit }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user