added IsURLValid function
This commit is contained in:
@@ -17,7 +17,7 @@ $MSPRoot, $MSPScripts, $MSPTools, $MSPLogs | ForEach-Object {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
## Set a datestamp for any log files that might need to be created
|
## Set a file prefix for any logs that might need to be created
|
||||||
$LogFilePrefix = Get-Date -Format "yyyyMMddHHmmss"
|
$LogFilePrefix = Get-Date -Format "yyyyMMddHHmmss"
|
||||||
|
|
||||||
## Function to log activity to the configured log directory
|
## Function to log activity to the configured log directory
|
||||||
@@ -137,6 +137,11 @@ param(
|
|||||||
)
|
)
|
||||||
$LogName = $MyInvocation.MyCommand
|
$LogName = $MyInvocation.MyCommand
|
||||||
If ( $Arguments -eq "null" ) { $Arguments = $null }
|
If ( $Arguments -eq "null" ) { $Arguments = $null }
|
||||||
|
If ( $LivePSScript )
|
||||||
|
{
|
||||||
|
$URL = "https://dev.emberkom.com/emberkom/${Type}/raw/branch/master/${LivePSScript}.ps1"
|
||||||
|
If ( !(IsURLValid -URL $URL) ) { Log "The specified script does not exist: ${LivePSScript}" -Name $LogName ; Exit }
|
||||||
|
}
|
||||||
If ( $Path ) { If ( !(Test-Path $Path) ) { Log "The specified script does not exist: ${Path}" -Name $LogName ; Exit } }
|
If ( $Path ) { If ( !(Test-Path $Path) ) { Log "The specified script does not exist: ${Path}" -Name $LogName ; Exit } }
|
||||||
If ( ($HaltIfRunning) -and ($ForceClose) -and ( !(IsAdmin) ) ) { Log "Cannot close dependent apps because this task does not have administrative privileges" -Name $LogName ; Exit }
|
If ( ($HaltIfRunning) -and ($ForceClose) -and ( !(IsAdmin) ) ) { Log "Cannot close dependent apps because this task does not have administrative privileges" -Name $LogName ; Exit }
|
||||||
If ( $HaltIfRunning )
|
If ( $HaltIfRunning )
|
||||||
@@ -164,7 +169,6 @@ switch ($PSCmdlet.ParameterSetName)
|
|||||||
{
|
{
|
||||||
'live-ps'
|
'live-ps'
|
||||||
{
|
{
|
||||||
$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 ; Exit }
|
Catch { $_.Exception.Message | Log -Name $LogName ; Exit }
|
||||||
@@ -205,6 +209,18 @@ For ($i = 0; $i -le ($Sets - 1); $i++)
|
|||||||
Return [version]$Return.Trim('.')
|
Return [version]$Return.Trim('.')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
## Determines whether a URL is valid
|
||||||
|
Function IsURLValid
|
||||||
|
{
|
||||||
|
param([Parameter(Mandatory=$true,ValueFromPipeline=$true)][string]$URL)
|
||||||
|
$HTTPRequest = [System.Net.WebRequest]::Create($URL)
|
||||||
|
$HTTPResponse = $HTTPRequest.GetResponse()
|
||||||
|
$HTTPStatus = [int]$HTTPResponse.StatusCode
|
||||||
|
$HTTPResponse.Close()
|
||||||
|
If ($HTTPStatus -eq 200) { Return $true }
|
||||||
|
Else { Return $false }
|
||||||
|
}
|
||||||
|
|
||||||
## Function to compare current Windows version with a supplied version
|
## Function to compare current Windows version with a supplied version
|
||||||
## The value supplied must be a string and must include at least 1 decimal
|
## The value supplied must be a string and must include at least 1 decimal
|
||||||
Function IsWindowsVersion
|
Function IsWindowsVersion
|
||||||
|
|||||||
Reference in New Issue
Block a user