2020-08-09 17:52:30 -04:00
|
|
|
#Requires -Version 2.0
|
|
|
|
|
|
2020-08-18 21:47:08 -04:00
|
|
|
param(
|
|
|
|
|
[string]$Type='management-scripts',
|
|
|
|
|
[string]$Name,
|
|
|
|
|
[string]$Arguments)
|
|
|
|
|
|
|
|
|
|
## Form the URL to the specified script
|
|
|
|
|
$URL = "https://dev.emberkom.com/emberkom/${Type}/raw/branch/master/${Name}.ps1"
|
|
|
|
|
|
|
|
|
|
## Get the script
|
|
|
|
|
Write-Output "Retrieving script: ${Name}"
|
|
|
|
|
Try { $Script = (New-Object Net.WebClient).DownloadString($URL) }
|
|
|
|
|
Catch { Write-Output $_.Exception.Message }
|
|
|
|
|
|
|
|
|
|
## Make a script block
|
|
|
|
|
Write-Output "Creating scriptblock"
|
|
|
|
|
Try { $ScriptBlock = [Scriptblock]::Create($Script) }
|
|
|
|
|
Catch { Write-Output $_.Exception.Message }
|
|
|
|
|
|
|
|
|
|
## Run the script any any arguments
|
|
|
|
|
Write-Output "${Name}.ps1 ${Arguments}"
|
|
|
|
|
Try { Invoke-Command -ScriptBlock $ScriptBlock -ArgumentList $Arguments }
|
|
|
|
|
Catch { Write-Output $_.Exception.Message }
|
|
|
|
|
|
|
|
|
|
## Finish script
|
|
|
|
|
Write-Output "${Name}.ps1 has finished"
|