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