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