Skip to content

Commit 9bf04d2

Browse files
Merge pull request #35 from AngryProgrammerInside/6.0.1b
6.0.1
2 parents e74bda1 + ac5fc56 commit 9bf04d2

12 files changed

+461
-148
lines changed

AMPs/Agent AD Status.amp

Lines changed: 158 additions & 0 deletions
Large diffs are not rendered by default.

AMPs/Agent AD Status.ps1

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#region AMP startup variable. This region isn't in the the AMP itself.
2+
$NetworkFolder = "Agent"
3+
$GPOName = "n-able - Install Agent (PS)"
4+
$NetLogonShare = "C:\Windows\SYSVOL\domain\scripts" # This is gathered inside the AMP
5+
#endregion
6+
7+
$PartnerConfigFile = $NetLogonShare + "\" + $NetworkFolder + "\PartnerConfig.xml"
8+
9+
Try {
10+
[xml]$PCXml = Get-Content -Path $PartnerConfigFile
11+
$PartnerConfigFileVersion = $PCXml.Config.Version
12+
$NCentralVersion = $PCXml.config.Deployment.Typical.SOAgentVersion
13+
$InstallationFile = Try {
14+
$NCentralFileVersion = $PCXml.config.Deployment.Typical.SOAgentFileVersion
15+
$SOFileVersion = [System.Diagnostics.FileVersionInfo]::GetVersionInfo("$NetLogonShare\$NetworkFolder\$($PCXml.config.Deployment.Typical.InstallFolder)\$($PCxml.Config.Deployment.Typical.SOAgentFileName)").FileVersion
16+
if ($NCentralFileVersion -eq "$SOFileVersion.0") { "INFO: File version OK" } else { "ERROR: Wrong Installer File" }
17+
}
18+
Catch {
19+
"ERROR: $($PCxml.Config.Deployment.Typical.SOAgentFileName) file not found"
20+
}
21+
$CustomerId = $PCXml.Config.Deployment.Typical.CustomerId
22+
$RegistrationToken = if ($PCXml.Config.Deployment.Typical.RegistrationToken) { "INFO: Present" } else { "ERROR: Registration token missing" }
23+
}
24+
Catch {
25+
$PartnerConfigFileVersion = "ERROR: PartnerConfig.xml file not found"
26+
$NCentralVersion = "ERROR: PartnerConfig.xml file not found"
27+
$InstallationFile = "ERROR: PartnerConfig.xml file not found"
28+
$CustomerID = 0
29+
$RegistrationToken = "ERROR: PartnerConfig.xml file not found"
30+
}
31+
32+
$OSVersion = [system.environment]::OSVersion.Version
33+
$GPOInstalled = if (($OSVersion.Major -eq 10) -or (($OSVersion.Major -eq 6) -and ($OSVersion.Minor -ge 2))) {
34+
(get-gpo -name $GPOName -ErrorAction ignore).Count
35+
}
36+
else {
37+
-1
38+
}

Agent/InstallAgent.ps1

Lines changed: 37 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
# Installation, Diagnostic and Repair Script for the N-Central Agent
22
# Original Script Created by Tim Wiser
3-
# Maintained by the Solarwinds MSP Community
3+
# Maintained by the N-able Community
44

55
################################
66
########## Change Log ##########
77
################################
88

9+
### 6.0.1 on 2021-04-12 - David Brooks & Robby Swartenbroekx
10+
##################################################################
11+
# See ReleaseNotes.md for all the changes
12+
913
### 6.0.0 on 2021-02-01 - David Brooks
1014
##################################################################
1115
# - Added various token registration method and agent activation methods
@@ -80,7 +84,7 @@
8084
# HOUSEKEEPING
8185
# - Re-published Change Log with most recent developments up top and some basic Categories for
8286
# updates
83-
# - Moved Script Execution Registry Key to HKLM:\SOFTWARE\Solarwinds MSP Community
87+
# - Moved Script Execution Registry Key to HKLM:\SOFTWARE\SolarWinds MSP Community
8488
# - Added a Legacy Version Cleanup section which will automatically remove values/files created by
8589
# older versions of the Script (Huge thanks to Tim and Jon for their contributions!)
8690
#
@@ -191,8 +195,8 @@ if ($DebugMode.IsPresent) {
191195
if (Get-Module InstallAgent-Core) {
192196
Remove-Module InstallAgent-Core
193197
}
194-
$AgentRegPath = "HKLM:\SOFTWARE\Solarwinds MSP Community\InstallAgent"
195-
if (Test-Path $AgentRegPath){
198+
$AgentRegPath = "HKLM:\SOFTWARE\N-able Community\InstallAgent"
199+
if (Test-Path $AgentRegPath) {
196200
Remove-Item $AgentRegPath -Recurse -Force
197201
}
198202
}
@@ -215,8 +219,8 @@ $NC.InstallParameters = @{
215219
}
216220
# Path Constants
217221
$NC.Paths = @{
218-
"BinFolder" = "N-Able Technologies\Windows Agent\bin"
219-
"ConfigFolder" = "N-Able Technologies\Windows Agent\config"
222+
"BinFolder" = "N-able Technologies\Windows Agent\bin"
223+
"ConfigFolder" = "N-able Technologies\Windows Agent\config"
220224
"UninstallKey32" = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"
221225
"UninstallKey64" = "HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall"
222226
}
@@ -286,7 +290,7 @@ $SC = @{
286290
}
287291
"RunningInstanceTimeout" = 30
288292
"ScriptEventLog" = "Application"
289-
"ScriptVersion" = "6.0.0"
293+
"ScriptVersion" = "6.0.1"
290294
"SuccessScriptAction" = "Graceful Exit"
291295
"SuccessScriptResult" = "Script Completed Successfully"
292296
}
@@ -309,88 +313,88 @@ $SC.ExitTypes = @{
309313
"E" = "Report This Error"
310314
}
311315
$SC.Exit = @{
312-
"Error" = @{
316+
"Error" = @{
313317
"ExitResult" = "Undocumented Error (See Event Log)"
314318
"ExitType" = $SC.ExitTypes.E
315319
}
316-
"A" = @{
320+
"A" = @{
317321
"ExitResult" = $SC.SuccessScriptResult
318322
"ExitType" = $SC.ExitTypes.A
319323
}
320-
"B" = @{
324+
"B" = @{
321325
"ExitResult" = "Partner Configuration File is Missing"
322326
"ExitType" = $SC.ExitTypes.B
323327
}
324-
"C" = @{
328+
"C" = @{
325329
"ExitResult" = "Partner Configuration is Invalid"
326330
"ExitType" = $SC.ExitTypes.B
327331
}
328-
"D" = @{
332+
"D" = @{
329333
"ExitResult" = "No Installation Sources Available"
330334
"ExitType" = $SC.ExitTypes.B
331335
}
332-
"E" = @{
336+
"E" = @{
333337
"ExitResult" = "Installer File is Missing"
334338
"ExitType" = $SC.ExitTypes.B
335339
}
336-
"F" = @{
340+
"F" = @{
337341
"ExitResult" = "Installer Version Mismatch"
338342
"ExitType" = $SC.ExitTypes.B
339343
}
340-
"G" = @{
344+
"G" = @{
341345
"ExitResult" = ("Unable to Reach " + $NC.Products.NCServer.Name)
342346
"ExitType" = $SC.ExitTypes.C
343347
}
344-
"H" = @{
348+
"H" = @{
345349
"ExitResult" = "Customer ID Parameter Required"
346350
"ExitType" = $SC.ExitTypes.B
347351
}
348-
"I" = @{
352+
"I" = @{
349353
"ExitResult" = "Customer ID Parameter Invalid"
350354
"ExitType" = $SC.ExitTypes.B
351355
}
352-
"J" = @{
356+
"J" = @{
353357
"ExitResult" = "Windows Installer Service Unavailable"
354358
"ExitType" = $SC.ExitTypes.D
355359
}
356-
"K" = @{
360+
"K" = @{
357361
"ExitResult" = ".NET Framework Installation Failed"
358362
"ExitType" = $SC.ExitTypes.D
359363
}
360-
"L" = @{
364+
"L" = @{
361365
"ExitResult" = "Agent Removal Failed"
362366
"ExitType" = $SC.ExitTypes.D
363367
}
364-
"M" = @{
368+
"M" = @{
365369
"ExitResult" = "No Installation Methods Remaining"
366370
"ExitType" = $SC.ExitTypes.D
367371
}
368-
"AA" = @{
372+
"AA" = @{
369373
"ExitMessage" = "An invalid Parameter value or type was provided to a Script Function."
370374
"ExitResult" = "Invalid Parameter"
371375
"ExitType" = $SC.ExitTypes.E
372376
}
373-
"AB" = @{
377+
"AB" = @{
374378
"ExitMessage" = ("The current " + $NC.Products.Agent.Name + " installation requires repair, but no Repairs were selected to be applied.")
375379
"ExitResult" = "No Repairs Selected"
376380
"ExitType" = $SC.ExitTypes.E
377381
}
378-
"AC" = @{
382+
"AC" = @{
379383
"ExitMessage" = "An error occurred during a file transfer and the Script cannot proceed."
380384
"ExitResult" = "File Transfer Failed"
381385
"ExitType" = $SC.ExitTypes.E
382386
}
383-
"AD" = @{
387+
"AD" = @{
384388
"ExitMessage" = "The file at the specified path does not exist."
385389
"ExitResult" = "File Not Found"
386390
"ExitType" = $SC.ExitTypes.E
387391
}
388-
"AE" = @{
392+
"AE" = @{
389393
"ExitMessage" = "An error occurred during item creation and the Script cannot proceed."
390394
"ExitResult" = "File/Folder Creation Failed"
391395
"ExitType" = $SC.ExitTypes.E
392396
}
393-
"LEGACY" = @{
397+
"AF" = @{
394398
"ExitMessage" = "The agent could not be installed on this legacy platform."
395399
"ExitResult" = "Legacy installation unavailable"
396400
"ExitType" = $SC.ExitTypes.E
@@ -482,7 +486,7 @@ $SC.Names = @{
482486
}
483487
# Path Constants
484488
$SC.Paths = @{
485-
"ExecutionKey" = "HKLM:\SOFTWARE\Solarwinds MSP Community"
489+
"ExecutionKey" = "HKLM:\SOFTWARE\N-able Community"
486490
"ServiceKey" = "HKLM:\SYSTEM\CurrentControlSet\Services"
487491
"TempFolder" = Split-Path $MyInvocation.MyCommand.Path -Parent
488492
}
@@ -575,13 +579,14 @@ $SC.Validation = @{
575579
}
576580
### Retired Values - PLACE RETIRED VALUES HERE TO CLEANUP OLD SCRIPT ENTRIES
577581
$SC.Paths.Old = @{
578-
"ExecutionKeyTim" = "HKLM:\SOFTWARE\Tim Wiser"
579-
"ExecutionKey" = "HKLM:\SOFTWARE\N-Central"
580-
"EventKey" = "HKLM:\SYSTEM\CurrentControlSet\Services\EventLog\InstallAgent"
582+
"ExecutionKeySolarWinds" = "HKLM:\SOFTWARE\SolarWinds MSP Community"
583+
"ExecutionKeyTim" = "HKLM:\SOFTWARE\Tim Wiser"
584+
"ExecutionKey" = "HKLM:\SOFTWARE\N-Central"
585+
"EventKey" = "HKLM:\SYSTEM\CurrentControlSet\Services\EventLog\InstallAgent"
581586
}
582587

583588
function GetCustomInstallMethods {
584-
# An empty function for a partner to override and update/insert custom install information
589+
# An empty function for a partner to override and update/insert custom install information
585590
}
586591

587592

Agent/LaunchInstaller.ps1

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ param (
22
[Switch]$Monitor
33
)
44
### 1.0.0 on 2021-02-21 - David Brooks, Premier Technology Solutions
5-
##################################################################
5+
### 1.0.1 on 2021-03-23 - Robby Swartenbroekx, b-inside bv
6+
####################################################################
67
# - Adapted updated Batch file version of InstallAgent to PowerShell
78
Write-Host "CustomerID: $($args[0])" -ForegroundColor Green
89
Write-Host "Token: $($args[1])" -ForegroundColor Green
@@ -76,12 +77,16 @@ if ($null -eq $p) {
7677
Write-EventLog -EntryType Error -EventId 13 -LogName Application -Source $LauncherScript -Message "$SetupScript encountered an error starting the launcher" > $null
7778
Exit 2
7879
}
80+
else {
81+
Write-Host "Successfully launched $TempFolder\InstallAgent.ps1 with $($args.Count) arguments" -ForegroundColor Green
82+
Write-EventLog -EntryType Information -EventId 10 -LogName Application -Source $LauncherScript -Message "Successfully launched $TempFolder\InstallAgent.ps1 with $($args.Count) arguments" > $null
83+
}
7984

8085
Write-Host "Launched InstallAgent with PID: $($p.Id), waiting on Exit"
8186
$RegPaths = @{
82-
Summary = "HKLM:\SOFTWARE\Solarwinds MSP Community\InstallAgent"
83-
Installation = "HKLM:\SOFTWARE\Solarwinds MSP Community\InstallAgent\Installation"
84-
Diagnosis = "HKLM:\SOFTWARE\Solarwinds MSP Community\InstallAgent\Diagnosis"
87+
Summary = "HKLM:\SOFTWARE\N-able Community\InstallAgent"
88+
Installation = "HKLM:\SOFTWARE\N-able Community\InstallAgent\Installation"
89+
Diagnosis = "HKLM:\SOFTWARE\N-able Community\InstallAgent\Diagnosis"
8590
}
8691

8792
while (-not $p.HasExited) {
@@ -92,7 +97,8 @@ while (-not $p.HasExited) {
9297
Write-Host "Progress: " -ForegroundColor Green -NoNewline
9398
Get-ItemProperty $RegPaths.Summary | Select-Object * -ExcludeProperty PS* | Format-List *
9499
}
95-
} else {
100+
}
101+
else {
96102
Start-Sleep 10
97103
}
98104
}

0 commit comments

Comments
 (0)