Skip to content

Commit

Permalink
Merge pull request #10 from N-able/6.0.2
Browse files Browse the repository at this point in the history
6.0.2 Production
  • Loading branch information
AngryProgrammerInside authored Jul 29, 2021
2 parents 5d63a8a + eae14a7 commit 1e86ec7
Show file tree
Hide file tree
Showing 52 changed files with 6,745 additions and 4,630 deletions.
158 changes: 158 additions & 0 deletions AMPs/Agent AD Status.amp

Large diffs are not rendered by default.

38 changes: 38 additions & 0 deletions AMPs/Agent AD Status.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#region AMP startup variable. This region isn't in the the AMP itself.
$NetworkFolder = "Agent"
$GPOName = "n-able - Install Agent (PS)"
$NetLogonShare = "C:\Windows\SYSVOL\domain\scripts" # This is gathered inside the AMP
#endregion

$PartnerConfigFile = $NetLogonShare + "\" + $NetworkFolder + "\PartnerConfig.xml"

Try {
[xml]$PCXml = Get-Content -Path $PartnerConfigFile
$PartnerConfigFileVersion = $PCXml.Config.Version
$NCentralVersion = $PCXml.config.Deployment.Typical.SOAgentVersion
$InstallationFile = Try {
$NCentralFileVersion = $PCXml.config.Deployment.Typical.SOAgentFileVersion
$SOFileVersion = [System.Diagnostics.FileVersionInfo]::GetVersionInfo("$NetLogonShare\$NetworkFolder\$($PCXml.config.Deployment.Typical.InstallFolder)\$($PCxml.Config.Deployment.Typical.SOAgentFileName)").FileVersion
if ($NCentralFileVersion -eq "$SOFileVersion.0") { "INFO: File version OK" } else { "ERROR: Wrong Installer File" }
}
Catch {
"ERROR: $($PCxml.Config.Deployment.Typical.SOAgentFileName) file not found"
}
$CustomerId = $PCXml.Config.Deployment.Typical.CustomerId
$RegistrationToken = if ($PCXml.Config.Deployment.Typical.RegistrationToken) { "INFO: Present" } else { "ERROR: Registration token missing" }
}
Catch {
$PartnerConfigFileVersion = "ERROR: PartnerConfig.xml file not found"
$NCentralVersion = "ERROR: PartnerConfig.xml file not found"
$InstallationFile = "ERROR: PartnerConfig.xml file not found"
$CustomerID = 0
$RegistrationToken = "ERROR: PartnerConfig.xml file not found"
}

$OSVersion = [system.environment]::OSVersion.Version
$GPOInstalled = if (($OSVersion.Major -eq 10) -or (($OSVersion.Major -eq 6) -and ($OSVersion.Minor -ge 2))) {
(get-gpo -name $GPOName -ErrorAction ignore).Count
}
else {
-1
}
60 changes: 60 additions & 0 deletions AMPs/Refresh Agent Token.amp
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?xml version="1.0" encoding="utf-8" standalone="yes"?><Policy ID="9548e8a4-b3b5-4f80-bb04-e58046f14b4d" Name="Refresh Agent Token" Description="IyBBTVBMaWZpZWQgdmVyc2lvbiBvZiBBTUUtSnVzdGluJ3MgdG9rZW4gcmVmcmVzaCBzY3JpcHQgYXMgaW5zcGlyZWQgYnkgQ2hyaXMgUmVpZCwgYnkgRGF2aWQgQnJvb2tzDQojIFZlcnNpb24gMS4wLjANCiMgTm90ZTogUmVxdWlyZXMgZm9sbG93aW5nIE5DIFJvbGUgcGVybWlzc2lvbnMNCiMgPiBEZXZpY2VzIC0+IE5ldHdvcmsgRGV2aWNlcyAtPiBFZGl0IERldmljZSBTZXR0aW5ncyBbUmVhZCBPbmx5XQ0KIyA+IERldmljZXMgLT4gTmV0d29yaw==" Version="2.15.1.3" RemoteCategory="0" ExecutionType="Local" MinimumPSVersionRequired="0.0.0">
<Object ID="{436f946e-cc9c-4fcc-a1c0-1905a73f63fe}" Type="{B6FA6D8B-EEAA-47A6-8463-7F9A4F5BBB6E}" Data="&lt;xml&gt;&lt;Parameters&gt;&lt;Parameter ParameterName=&quot;username&quot; Label=&quot;Username&quot; ParameterType=&quot;string&quot; Value=&quot;&quot; /&gt;&lt;Parameter ParameterName=&quot;password&quot; Label=&quot;Password&quot; ParameterType=&quot;password&quot; Value=&quot;&quot; /&gt;&lt;Parameter ParameterName=&quot;serverHost&quot; Label=&quot;N-Central FQDN&quot; ParameterType=&quot;string&quot; Value=&quot;&quot; /&gt;&lt;Parameter ParameterName=&quot;expirationTolerance&quot; Label=&quot;Expiration Tolerance&quot; ParameterType=&quot;number&quot; Value=&quot;&quot; /&gt;&lt;Parameter ParameterName=&quot;JWT&quot; Label=&quot;JWT&quot; ParameterType=&quot;password&quot; Value=&quot;&quot; /&gt;&lt;/Parameters&gt;&lt;/xml&gt;" />
<LinkManager xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/PolicyExecutor">
<hashset xmlns:d2p1="http://schemas.datacontract.org/2004/07/System" />
</LinkManager>
<Activity mc:Ignorable="sads sap" x:Class="Policy Builder" xmlns="http://schemas.microsoft.com/netfx/2009/xaml/activities" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mva="clr-namespace:Microsoft.VisualBasic.Activities;assembly=System.Activities" xmlns:p="clr-namespace:PolicyExecutor;assembly=PolicyExecutionEngine" xmlns:sads="http://schemas.microsoft.com/netfx/2010/xaml/activities/debugger" xmlns:sap="http://schemas.microsoft.com/netfx/2009/xaml/activities/presentation" xmlns:scg="clr-namespace:System.Collections.Generic;assembly=mscorlib" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<x:Members>
<x:Property Name="PolicyGUID" Type="InArgument(x:String)" />
</x:Members>
<sap:VirtualizedContainerService.HintSize>504,745</sap:VirtualizedContainerService.HintSize>
<mva:VisualBasic.Settings>Assembly references and imported namespaces serialized as XML namespaces</mva:VisualBasic.Settings>
<p:PolicySequence DisplayName="Policy Builder" sap:VirtualizedContainerService.HintSize="504,745" mva:VisualBasic.Settings="Assembly references and imported namespaces serialized as XML namespaces">
<p:PolicySequence.Activities>
<p:RunPowerShellScript AssemblyName="PolicyExecutionEngine, Version=2.16.1.15, Culture=neutral, PublicKeyToken=null" DisplayName="Run PowerShell Script" sap:VirtualizedContainerService.HintSize="468,522" Moniker="7f8a62ca-e6ff-4bf1-9c9c-de8b19c4c94c" OutPut_64="[RunPowerShellScript_OutPut_64]" Result="[RunPowerShellScript_Result]" ResultString="[RunPowerShellScript_ResultString]" Results_x64="[RunPowerShellScript_Results_x64]" RunAsCurrentLoggedOnUser="False" ScriptExecutionMethod="ExecuteDebug" TypeName="RunPowerShellScript" genArgEvent="be5e37b6-00b5-46d1-b4fd-f5932cb40e8e" m_bTextLinkChange="False" script="IwAgAEEATQBQAEwAaQBmAGkAZQBkACAAdgBlAHIAcwBpAG8AbgAgAG8AZgAgAEEATQBFAC0ASgB1AHMAdABpAG4AJwBzACAAdABvAGsAZQBuACAAcgBlAGYAcgBlAHMAaAAgAHMAYwByAGkAcAB0ACAAYQBzACAAaQBuAHMAcABpAHIAZQBkACAAYgB5ACAAQwBoAHIAaQBzACAAUgBlAGkAZAAsACAAYgB5ACAARABhAHYAaQBkACAAQgByAG8AbwBrAHMADQAKACMAIABWAGUAcgBzAGkAbwBuACAAMQAuADAALgAwAA0ACgAjACAATgBvAHQAZQA6ACAAUgBlAHEAdQBpAHIAZQBzACAAZgBvAGwAbABvAHcAaQBuAGcAIABOAEMAIABSAG8AbABlACAAcABlAHIAbQBpAHMAcwBpAG8AbgBzAA0ACgAjACAAPgAgAEQAZQB2AGkAYwBlAHMAIAAtAD4AIABOAGUAdAB3AG8AcgBrACAARABlAHYAaQBjAGUAcwAgAC0APgAgAEUAZABpAHQAIABEAGUAdgBpAGMAZQAgAFMAZQB0AHQAaQBuAGcAcwAgAFsAUgBlAGEAZAAgAE8AbgBsAHkAXQANAAoAIwAgAD4AIABEAGUAdgBpAGMAZQBzACAALQA+ACAATgBlAHQAdwBvAHIAawAgAEQAZQB2AGkAYwBlAHMAIAAtAD4AIABSAGUAZwBpAHMAdAByAGEAdABpAG8AbgAgAFQAbwBrAGUAbgBzACAAWwBNAGEAbgBhAGcAZQBdAA0ACgANAAoAIwAgAEcAZQBuAGUAcgBhAHQAZQAgAGEAIABwAHMAZQB1AGQAbwAtAHUAbgBpAHEAdQBlACAAbgBhAG0AZQBzAHAAYQBjAGUAIAB0AG8AIAB1AHMAZQAgAHcAaQB0AGgAIAB0AGgAZQAgAE4AZQB3AC0AVwBlAG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QAZQB4AHAAaQByAGEAdABpAG8AbgBkAGEAdABlACAAPQAgAFsAZABhAHQAZQB0AGkAbQBlAF0AOgA6AFAAYQByAHMAZQBFAHgAYQBjAHQAKAAoACQAYwB1AHMAdABvAG0AZQByAC4AcgBlAGcAaQBzAHQAcgBhAHQAaQBvAG4AdABvAGsAZQBuAGUAeABwAGkAcgB5AGQAYQB0AGUAKQAuAHMAcABsAGkAdAAoACIAIAAiACkAWwAwAF0ALAAgACcAeQB5AHkAeQAtAE0ATQAtAGQAZAAnACwAIAAkAG4AdQBsAGwAKQANAAoAIAAgACAAIAAgACAAIAAgAGkAZgAgACgAJABlAHgAcABpAHIAYQB0AGkAbwBuAGQAYQB0AGUAIAAtAGwAdAAgACQAZABhAHQAZQAuAEEAZABkAEQAYQB5AHMAKAAkAGUAeABwAGkAcgBhAHQAaQBvAG4AVABvAGwAZQByAGEAbgBjAGUAKQApACAAewANAAoAIAAgACAAIAAgACAAIAAgACAAIAAgACAAdQBwAGQAYQB0AGUAdABvAGsAZQBuACgAJABjAHUAcwB0AG8AbQBlAHIAKQANAAoAIAAgACAAIAAgACAAIAAgAH0ADQAKACAAIAAgACAAfQANAAoAfQA=">
<p:RunPowerShellScript.InArgs>
<p:InArg Item="{x:Null}" ItemProp="{x:Null}" x:Key="username" ArgType="string" DisplayArg="Input Parameters.Username" DisplayName="username" Name="username" isRequired="False">
<p:InArg.Arg>
<InArgument x:TypeArguments="x:String">[username]</InArgument>
</p:InArg.Arg>
</p:InArg>
<p:InArg Item="{x:Null}" ItemProp="{x:Null}" x:Key="password" ArgType="password" DisplayArg="Input Parameters.Password" DisplayName="password" Name="password" isRequired="False">
<p:InArg.Arg>
<InArgument x:TypeArguments="p:Password">[password]</InArgument>
</p:InArg.Arg>
</p:InArg>
<p:InArg Item="{x:Null}" ItemProp="{x:Null}" x:Key="serverHost" ArgType="string" DisplayArg="Input Parameters.N-Central FQDN" DisplayName="serverHost" Name="serverHost" isRequired="False">
<p:InArg.Arg>
<InArgument x:TypeArguments="x:String">[serverHost]</InArgument>
</p:InArg.Arg>
</p:InArg>
<p:InArg Item="{x:Null}" ItemProp="{x:Null}" x:Key="expirationTolerance" ArgType="number" DisplayArg="Input Parameters.Expiration Tolerance" DisplayName="expirationTolerance" Name="expirationTolerance" isRequired="False">
<p:InArg.Arg>
<InArgument x:TypeArguments="x:Double">[expirationTolerance]</InArgument>
</p:InArg.Arg>
</p:InArg>
<p:InArg Item="{x:Null}" ItemProp="{x:Null}" x:Key="JWT" ArgType="password" DisplayArg="Input Parameters.JWT" DisplayName="JWT" Name="JWT" isRequired="False">
<p:InArg.Arg>
<InArgument x:TypeArguments="p:Password">[JWT]</InArgument>
</p:InArg.Arg>
</p:InArg>
</p:RunPowerShellScript.InArgs>
<p:RunPowerShellScript.OutArgs>
<scg:Dictionary x:TypeArguments="x:String, p:OutArg" />
</p:RunPowerShellScript.OutArgs>
</p:RunPowerShellScript>
</p:PolicySequence.Activities>
<p:PolicySequence.Variables>
<Variable x:TypeArguments="x:String" Name="username" />
<Variable x:TypeArguments="p:Password" Name="password" />
<Variable x:TypeArguments="x:String" Name="serverHost" />
<Variable x:TypeArguments="x:Double" Name="expirationTolerance" />
<Variable x:TypeArguments="x:String" Name="RunPowerShellScript_OutPut_64" />
<Variable x:TypeArguments="x:Double" Name="RunPowerShellScript_Result" />
<Variable x:TypeArguments="x:String" Name="RunPowerShellScript_ResultString" />
<Variable x:TypeArguments="scg:IEnumerable(x:Object)" Name="RunPowerShellScript_Results_x64" />
<Variable x:TypeArguments="p:Password" Name="JWT" />
</p:PolicySequence.Variables>
</p:PolicySequence>
</Activity>
</Policy>
73 changes: 73 additions & 0 deletions AMPs/Refresh Agent Token.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# AMPLified version of AME-Justin's token refresh script as inspired by Chris Reid, by David Brooks
# Version 1.0.0
# Note: Requires following NC Role permissions
# > Devices -> Network Devices -> Edit Device Settings [Read Only]
# > Devices -> Network Devices -> Registration Tokens [Manage]

<#region Input Parameters used in AMP:
$username
$password
$serverHost
$expirationTolerance
$JWT
#>

# Generate a pseudo-unique namespace to use with the New-WebServiceProxy and associated types.
$NWSNameSpace = "NAble" + ([guid]::NewGuid()).ToString().Substring(25)
$KeyPairType = "$NWSNameSpace.eiKeyValue"

# Bind to the namespace, using the Webserviceproxy
$bindingURL = "https://" + $serverHost + "/dms2/services2/ServerEI2?wsdl"
$nws = New-Webserviceproxy $bindingURL -Namespace ($NWSNameSpace)

# Set up and execute the query
$KeyPair = New-Object -TypeName $KeyPairType
$KeyPair.Key = 'listSOs'
$KeyPair.Value = "false"

#Attempt to connect
Try {
$CustomerList = $nws.customerList("", $JWT, $KeyPair)
}
Catch {
Write-Host "Could not connect: $($_.Exception.Message)"
exit
}

#Create customer report ArrayList
$Customers = New-Object System.Collections.ArrayList
ForEach ($Entity in $CustomerList) {
$CustomerAssetInfo = @{}
ForEach ($item in $Entity.items) { $CustomerAssetInfo[$item.key] = $item.Value }
$o = [PSCustomObject]@{
CustomerID = $CustomerAssetInfo["customer.customerid"]
Name = $CustomerAssetInfo["customer.customername"]
ParentID = $CustomerAssetInfo["customer.parentid"]
RegistrationToken = $CustomerAssetInfo["customer.registrationtoken"]
RegistrationTokenExpiryDate = $CustomerAssetInfo["customer.registrationtokenexpirydate"]
}
$Customers.Add($o) > $null
}

$SecurePass = ConvertTo-SecureString $password -AsPlainText -Force
$PSUserCredential = New-Object PSCredential ($username, $SecurePass)
$date = Get-Date

function updatetoken($customer) {
$uri = "https://$serverHost/dms/FileDownload?customerID=$($customer.customerid)&softwareID=101"
$ProgressPreference = 'SilentlyContinue'
Invoke-WebRequest -Uri $uri -UseBasicParsing -Credential $PSUserCredential | Out-Null
}
foreach ($customer in $customers) {
if (-not ($customer.registrationtokenexpirydate)) {
#No Registration Token
updatetoken($customer)
}
#Expires soon
else {
$expirationdate = [datetime]::ParseExact(($customer.registrationtokenexpirydate).split(" ")[0], 'yyyy-MM-dd', $null)
if ($expirationdate -lt $date.AddDays($expirationTolerance)) {
updatetoken($customer)
}
}
}
Loading

0 comments on commit 1e86ec7

Please sign in to comment.