source external scripts that have no arguments instead of running in scriptblock
This commit is contained in:
@@ -138,14 +138,19 @@ Function Run-Script {
|
||||
switch ($PSCmdlet.ParameterSetName) {
|
||||
'live-ps' {
|
||||
Write-Output "Retrieving : ${LivePSScript}.ps1"
|
||||
Try { $Script = (New-Object Net.WebClient).DownloadString($URL) }
|
||||
Catch { Write-Error $_.Exception.Message ; Exit }
|
||||
Try { $ScriptBlock = [Scriptblock]::Create($Script) }
|
||||
If ( $null -eq $Arguments ) {
|
||||
$ScriptFile = Download-File -URL $URL
|
||||
Write-Output "Sourcing: ${LivePSScript}.ps1"
|
||||
. $ScriptFile
|
||||
If ( Test-Path $ScriptFile ) { Remove-Item $ScriptFile -Force -ErrorAction SilentlyContinue }
|
||||
} Else {
|
||||
Try { $ScriptBlock = [Scriptblock]::Create((New-Object Net.WebClient).DownloadString($URL)) }
|
||||
Catch { Write-Error $_.Exception.Message ; Exit }
|
||||
Write-Output "Executing: ${LivePSScript}.ps1 ${Arguments}"
|
||||
Try { Invoke-Command -ScriptBlock $ScriptBlock -ArgumentList $Arguments }
|
||||
Catch { Write-Error $_.Exception.Message ; Exit }
|
||||
}
|
||||
}
|
||||
|
||||
'local' {
|
||||
Write-Output "Executing: ${Path} ${Arguments}"
|
||||
|
||||
Reference in New Issue
Block a user