update logging methods and fix Run-LocalInstallScript
This commit is contained in:
@@ -25,7 +25,7 @@ If ( !(Test-Path $MSPLogs) )
|
||||
Function Log
|
||||
{
|
||||
param(
|
||||
[Parameter(Mandatory=$true)][string]$Message,
|
||||
[Parameter(Mandatory=$true,ValueFromPipeline=$true)][string]$Message,
|
||||
[Parameter(Mandatory=$false)][switch]$Error,
|
||||
[Parameter(Mandatory=$false)][string]$LogName
|
||||
)
|
||||
@@ -57,12 +57,12 @@ If ( $Name -and $Type )
|
||||
$URL = "https://dev.emberkom.com/emberkom/${Type}/raw/branch/master/${Name}.ps1"
|
||||
Log "Retrieving : ${Name}.ps1"
|
||||
Try { $Script = (New-Object Net.WebClient).DownloadString($URL) }
|
||||
Catch { Log -Message $_.Exception.Message -Error }
|
||||
Catch { $_.Exception.Message | Log -Error }
|
||||
Try { $ScriptBlock = [Scriptblock]::Create($Script) }
|
||||
Catch { Log -Message $_.Exception.Message -Error }
|
||||
Catch { $_.Exception.Message | Log -Error }
|
||||
Log "Executing: ${Name}.ps1 ${Arguments}"
|
||||
Try { Invoke-Command -ScriptBlock $ScriptBlock -ArgumentList $Arguments }
|
||||
Catch { Log -Message $_.Exception.Message -Error }
|
||||
Catch { $_.Exception.Message | Log -Error }
|
||||
} Else { Log "No script or type was specified" }
|
||||
}
|
||||
|
||||
@@ -74,11 +74,10 @@ param(
|
||||
[Parameter(Mandatory=$true)][string]$Arguments,
|
||||
[Parameter(Mandatory=$true)][string]$AppName
|
||||
)
|
||||
If ( $AppName -eq "null" ) { $AppName = $false }
|
||||
If ( $Arguments -eq "null" ) { $Arguments = $null }
|
||||
If ( Test-Path "${Script}" )
|
||||
{
|
||||
If ( $AppName )
|
||||
If ( $AppName -ne "null" )
|
||||
{
|
||||
Log "Checking for running instances of ${AppName}"
|
||||
$RunningInstances = Get-Process | Where { $_.Name -like "${AppName}" }
|
||||
@@ -86,15 +85,15 @@ If ( Test-Path "${Script}" )
|
||||
{
|
||||
Log "Executing: ${Script} ${Arguments}"
|
||||
Try { Start-Process "${Script}" -ArgumentList "{$Arguments}" -Wait }
|
||||
Catch { Log -Message $_.Exception.Message -Error }
|
||||
Catch { $_.Exception.Message | Log -Error }
|
||||
}
|
||||
Else { Log "${AppName} is currently in use and will not be installed now" }
|
||||
Else { Log "Dependent apps are currently in use and preventing the specified script from running" }
|
||||
}
|
||||
Else
|
||||
{
|
||||
Log "Executing: ${Script} ${Arguments}"
|
||||
Try { Start-Process "${Script}" -ArgumentList "{$Arguments}" -Wait }
|
||||
Catch { Log -Message $_.Exception.Message -Error }
|
||||
Catch { $_.Exception.Message | Log -Error }
|
||||
}
|
||||
}
|
||||
Else { Log "The specified script does not exist: ${Script}" }
|
||||
|
||||
Reference in New Issue
Block a user