prevent double output for conditional

This commit is contained in:
2020-09-24 13:44:51 -04:00
parent 9f0a1076fd
commit 4d636246e7
2 changed files with 1 additions and 60 deletions
+1 -60
View File
@@ -38,7 +38,7 @@ If ( $Name )
Add-Content -Path $LogFile -Value $LogEntry
Write-Output $LogEntry
}
Write-Output $LogEntry
Else { Write-Output $LogEntry }
}
## Function to determine if the current user context is an Administrator
@@ -48,65 +48,6 @@ If ( ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]:
{ Return $true } Else { Return $false }
}
## Runs a script from the repo
Function Run-PSScript
{
param(
[Parameter(Mandatory=$false)][string]$Type='management-scripts',
[Parameter(Mandatory=$true)][string]$Name,
[Parameter(Mandatory=$false)][string]$Arguments="null"
)
$LogName = $MyInvocation.MyCommand
If ( $Arguments -eq "null" ) { $Arguments = $null }
If ( $Name )
{
$URL = "https://dev.emberkom.com/emberkom/${Type}/raw/branch/master/${Name}.ps1"
Log "Retrieving : ${Name}.ps1" -Name $LogName
Try { $Script = (New-Object Net.WebClient).DownloadString($URL) }
Catch { $_.Exception.Message | Log -Error -Name $LogName }
Try { $ScriptBlock = [Scriptblock]::Create($Script) }
Catch { $_.Exception.Message | Log -Error -Name $LogName }
Log "Executing: ${Name}.ps1 ${Arguments}" -Name $LogName
Try { Invoke-Command -ScriptBlock $ScriptBlock -ArgumentList $Arguments }
Catch { $_.Exception.Message | Log -Error -Name $LogName }
}
Else { Log "No script was specified" -Name $LogName }
}
## Runs a script local to the endpoint
Function Run-LocalInstallScript
{
param(
[Parameter(Mandatory=$true)][string]$Script,
[Parameter(Mandatory=$false)][string]$Arguments="null",
[Parameter(Mandatory=$false)][string]$AppName="null"
)
$LogName = $MyInvocation.MyCommand
If ( $Arguments -eq "null" ) { $Arguments = $null }
If ( Test-Path $Script )
{
If ( $AppName -ne "null" )
{
Log "Checking for running instances of ${AppName}" -Name $LogName
$RunningInstances = Get-Process | Where { $_.Name -like "${AppName}" }
If ( !($RunningInstances) )
{
Log "Executing: ${Script} ${Arguments}" -Name $LogName
Try { Start-Process "${Script}" -ArgumentList "${Arguments}" -Wait }
Catch { $_.Exception.Message | Log -Error -Name $LogName }
}
Else { Log "Dependent apps are currently in use and preventing the specified script from running" -Name $LogName }
}
Else
{
Log "Executing: ${Script} ${Arguments}" -Name $LogName
Try { Start-Process "${Script}" -ArgumentList "{$Arguments}" -Wait }
Catch { $_.Exception.Message | Log -Error -Name $LogName }
}
}
Else { Log "The specified script does not exist: ${Script}" -Name $LogName }
}
## Run a script from the live repo or from a local path
Function Run-Script
{