You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
49 lines
1.4 KiB
49 lines
1.4 KiB
<# |
|
.SYNOPSIS |
|
Entry point agent GeoNetAgent untuk user - sekali run / double-click. |
|
|
|
.DESCRIPTION |
|
Jalankan dari share IT, mis.: |
|
\\10.100.1.10\software installer\GeonetAgent\agent\UserAgent.ps1 |
|
|
|
Membaca config global config.json di folder yang sama (collector URL + token). |
|
Tidak perlu config per laptop - hostname dan identitas diambil otomatis dari WMI. |
|
|
|
.EXAMPLE |
|
powershell -NoProfile -ExecutionPolicy Bypass -File "\\10.100.1.10\software installer\GeonetAgent\agent\UserAgent.ps1" |
|
#> |
|
[CmdletBinding()] |
|
param( |
|
[switch]$IncludeSoftware |
|
) |
|
|
|
$ErrorActionPreference = 'Stop' |
|
$agentRoot = Split-Path -Parent $MyInvocation.MyCommand.Path |
|
$sendScript = Join-Path $agentRoot 'Send-GeoNetReport.ps1' |
|
$configPath = Join-Path $agentRoot 'config.json' |
|
|
|
if (-not (Test-Path $configPath)) { |
|
$shareTemplate = Join-Path $agentRoot 'config.share.json' |
|
if (Test-Path $shareTemplate) { |
|
Write-Warning 'config.json tidak ada - memakai config.share.json. Di share QNAP rename ke config.json.' |
|
$configPath = $shareTemplate |
|
} |
|
} |
|
|
|
if (-not (Test-Path $sendScript)) { |
|
throw "Send-GeoNetReport.ps1 tidak ditemukan di: $agentRoot" |
|
} |
|
|
|
if (-not (Test-Path $configPath)) { |
|
throw "config.json tidak ditemukan di: $agentRoot. Copy config.share.json ke config.json di share IT." |
|
} |
|
|
|
$params = @{ |
|
ConfigPath = $configPath |
|
} |
|
if ($IncludeSoftware) { |
|
$params['IncludeSoftware'] = $true |
|
} |
|
|
|
& $sendScript @params |
|
exit $LASTEXITCODE
|
|
|