Skip to content

Commit

Permalink
Merge pull request #866 from silversword411/develop
Browse files Browse the repository at this point in the history
docs: gpo script update and wip script for api example
  • Loading branch information
wh1te909 committed Dec 14, 2021
2 parents 0c450a5 + f259c25 commit d726bcd
Show file tree
Hide file tree
Showing 2 changed files with 101 additions and 12 deletions.
43 changes: 31 additions & 12 deletions docs/docs/install_agent.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,18 +93,37 @@ If you want to deploy the TRMM agent using AD, intune, mesh, teamviewer, Group P
You will need to replace `deployment url` with your custom deployment URL

```bat
if not exist C:\TEMP\TRMM md C:\TEMP\TRMM
powershell Set-ExecutionPolicy -ExecutionPolicy Unrestricted
powershell Add-MpPreference -ExclusionPath C:\TEMP\TRMM
powershell Add-MpPreference -ExclusionPath "C:\Program Files\TacticalAgent\*"
powershell Add-MpPreference -ExclusionPath C:\Windows\Temp\winagent-v*.exe
powershell Add-MpPreference -ExclusionPath "C:\Program Files\Mesh Agent\*"
powershell Add-MpPreference -ExclusionPath C:\Windows\Temp\TRMM\*
cd c:\temp\trmm
powershell Invoke-WebRequest "deployment url" -Outfile tactical.exe
"C:\Program Files\TacticalAgent\unins000.exe" /VERYSILENT /SUPPRESSMSGBOXES /FORCECLOSEAPPLICATIONS
start tactical.exe
powershell Remove-MpPreference -ExclusionPath C:\TEMP\TRMM
@echo off
REM Setup deployment URL
set "DeploymentURL="
set "Name="
for /f "usebackq tokens=* delims=" %%# in (
`wmic service where "name like 'tacticalagent'" get Name /Format:Value`
) do (
for /f "tokens=* delims=" %%g in ("%%#") do set "%%g"
)
if not defined Name (
echo Tactical RMM not found, installing now.
if not exist C:\TEMP\TRMM md C:\TEMP\TRMM
powershell Set-ExecutionPolicy -ExecutionPolicy Unrestricted
powershell Add-MpPreference -ExclusionPath C:\TEMP\TRMM
powershell Add-MpPreference -ExclusionPath "C:\Program Files\TacticalAgent\*"
powershell Add-MpPreference -ExclusionPath C:\Windows\Temp\winagent-v*.exe
powershell Add-MpPreference -ExclusionPath "C:\Program Files\Mesh Agent\*"
powershell Add-MpPreference -ExclusionPath C:\Windows\Temp\TRMM\*
cd c:\temp\trmm
powershell Invoke-WebRequest "%DeploymentURL%" -Outfile tactical.exe
REM"C:\Program Files\TacticalAgent\unins000.exe" /VERYSILENT /SUPPRESSMSGBOXES /FORCECLOSEAPPLICATIONS
tactical.exe
powershell Remove-MpPreference -ExclusionPath C:\TEMP\TRMM
rem exit /b 1
) else (
echo Tactical RMM already installed Exiting
Exit 0
)
```

There is also a full powershell version [here](https://wh1te909.github.io/tacticalrmm/3rdparty_screenconnect/#install-tactical-rmm-via-screeconnect-commands-window)
70 changes: 70 additions & 0 deletions scripts_wip/Win_TRMM_New_AgentviaAPI.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# From Chase 12/14/2021

function Create-TacticalRMMClient {

param(
$APIKey,
$Customer,
$Site,
$URL
)

$Headers = @{
"Content-Type" = "application/json"
"X-API-KEY" = $APIKey
}

$AllClients = Invoke-RestMethod -Uri "$URL/clients/" -Headers $Headers -Method GET -UseBasicParsing

$ClientCheck = ($AllClients | Where name -eq $Customer)

if (!$ClientCheck) {

$CreateClientBody = @"
{
"client": {"name": "$Customer"},
"site": {"name": "Unspecified"},
"custom_fields": []
}
"@

Invoke-RestMethod -URI "$URL/clients/" -Headers $Headers -Method Post -Body $CreateClientBody -UseBasicParsing | Out-Null

$NewSearch = Invoke-RestMethod -Uri "$URL/clients/" -Headers $Headers -Method GET -UseBasicParsing

$ClientID = ($NewSearch | Where { $_.name -eq $Customer }).id
$ClientName = ($NewSearch | Where { $_.name -eq $Customer }).name
$ClientSites = ($NewSearch | Where { $_.name -eq $Customer }).sites

}
else {
$ClientID = $ClientCheck.ID
$ClientName = $ClientCheck.Name
$ClientSites = $ClientCheck.Sites
}

$SiteCheck = ($ClientSites | Where Name -eq $Site)

if (!$SiteCheck) {

$CreateSiteBody = @"
{
"site": {"client": $ClientID, "name": "$Site"},
"custom_fields": []
}
"@

Invoke-RestMethod -Uri "$URL/clients/sites/" -Headers $Headers -Method POST -Body $CreateSiteBody -UseBasicParsing | Out-Null

$SiteNewSearch = (Invoke-RestMethod -Uri "$URL/clients/$ClientID/" -Headers $Headers -Method GET -UseBasicParsing).sites
$SiteID = ($SiteNewSearch | Where name -eq $Site).id
}



$Output = @()
$Output += New-Object -TypeName psobject -Property @{ClientID = "$ClientID"; SiteID = "$SiteID" }

Write-Output $Output

}

0 comments on commit d726bcd

Please sign in to comment.