forked from RuiRomano/pbigtwmonitor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Run.ps1
56 lines (40 loc) · 1.14 KB
/
Run.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#requires -Version 7 -Modules Az.Accounts, Az.Storage
param(
[string]$configFilePath = ".\Config.json"
,
[array]$scriptsToRun = @(
".\UploadGatewayLogs.ps1"
)
)
$ErrorActionPreference = "Stop"
$currentPath = (Split-Path $MyInvocation.MyCommand.Definition -Parent)
Set-Location $currentPath
Import-Module "$currentPath\Utils.psm1" -Force
Write-Host "Current Path: $currentPath"
Write-Host "Config Path: $configFilePath"
if (Test-Path $configFilePath) {
$config = Get-Content $configFilePath | ConvertFrom-Json
# Default Values
if (!$config.OutputPath) {
$config | Add-Member -NotePropertyName "OutputPath" -NotePropertyValue ".\\Data" -Force
}
}
else {
throw "Cannot find config file '$configFilePath'"
}
try {
foreach ($scriptToRun in $scriptsToRun)
{
try {
Write-Host "Running '$scriptToRun'"
& $scriptToRun -config $config
}
catch {
Write-Error "Error on '$scriptToRun' - $($_.Exception.ToString())" -ErrorAction Continue
}
}
}
catch {
$ex = $_.Exception
throw
}