Skip to main content
Question

Bulk download bestanden gekoppeld aan Assets

  • February 4, 2026
  • 3 replies
  • 22 views

Sanne Haller
Forum|alt.badge.img+3

Is het mogelijk om documenten gekoppeld aan een set/soort specifieke assets in één keer te downloaden?

3 replies

Forum|alt.badge.img+6

Hi ​@SahinS,

Vanuit welk perspectief vraag je dit? Vanuit een eindgebruiker of vanuit een beheerder? En, wil je dit vanuit de TOPdesk interface of is een script ook prima?


Sanne Haller
Forum|alt.badge.img+3
  • Author
  • Starter
  • February 9, 2026

Hi ​@SahinS,

Vanuit welk perspectief vraag je dit? Vanuit een eindgebruiker of vanuit een beheerder? En, wil je dit vanuit de TOPdesk interface of is een script ook prima?

Vanuit de ICT Servicedesk, dus een behandelaar.
Liefst vanuit de interface, maar heb ondertussen reactie van Support dat dit niet mogelijk is.
Ga nog kijken of ik tijd heb om zelf iets met api te doen, al verwacht ik niet dat dat helemaal een sluitende oplossing gaat zijn voor ons gezien je dan een lijst met download url's krijgt.

Maar bedankt voor meedenken, dacht laat ik het toch ook via de community vragen :)


Forum|alt.badge.img+6

Hi ​@Sanne Haller,

Ik heb wel een PowerShell script voor je, die dit kan. Belangrijk is dat je een API account hebt met minimale rechten (API access, read access asset).

De volgende variabelen dien je aan te passen

  • TOPdeskUrl (line 291)
  • Username (line 294)
  • ApplicationPassword (line 297)
  • TemplatesName (line 302)
  • DownloadFolder (line 306)

Om onderstaande uit te kunnen voeren:

  1. Open PowerShell ISE
  2. Kopieer onderstaande inhoud en plak het binnen PowerShell ISE
  3. Sla het bestand op (Bijv bulkDownloadAssetFiles.ps1)
  4. Pas de variables aan
  5. Voer het script uit
 Function Get-TopdeskAMAssets {

<#

.SYNOPSIS
Return the linked stock ID of an Asset

.DESCRIPTION
Return the linked stock ID of an Asset

.PARAMETER URL
Base TOPdesk URL (e.g., https://customer.topdesk.net).

.PARAMETER Username
API username used for authentication.

.PARAMETER ApplicationPassword
API application password for Basic Authentication.

.PARAMETER TemplateIds
...

.EXAMPLE
PS C:\> ...

.NOTES
Author : Rico Roodenburg
Author email : r.roodenburg@syntrophos.nl
Version : 1.0

===Tested Against Environment====
TOPdesk API version : 1.49.1
PowerShell Version : 5.1

#>

Param (

[Parameter(Position=0, Mandatory = $true)]
[string]$URL,

[Parameter(Position=1, Mandatory = $true)]
[string]$Username,

[Parameter(Position=2, Mandatory = $true)]
[string]$ApplicationPassword,

[Parameter(Position=3, Mandatory = $true)]
[string[]]$templateNames

)

Begin {

$Headers = @{

Authorization = "Basic " + [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes("$($Username):$($ApplicationPassword)"))

}

$Result = @()
$LastResult = "*"

}

Process {

DO {

Try {

$Temp = Invoke-RestMethod -Uri "$URL/tas/api/assetmgmt/assets?archived=false&templateName=$(@($templateNames) -join "&templateName=")&showAssignments=true&fields=name&`$filter=name gt '$($LastResult)'&fetchCount=true&resolveDropdownOptions=true&pageSize=1000" -Headers $Headers -Method Get -ContentType "application/x.topdesk-am-assets-v2+json" -ErrorAction Stop

} Catch {

# Error...
Write-Debug (">> Error while getting the options of the dropdownlist $DropdownField within TOPdesk, see error code below..")
Write-Debug ("StatusCode:" + $_.Exception.Response.StatusCode.value__ )
Write-Debug ("StatusDescription:" + $_.Exception.Response.StatusDescription)
Write-Debug ("Error: " + $_.ErrorDetails.Message)

}

$Result += $Temp.dataSet
$LastResult = $($Temp.dataSet[-1].name)

} Until(!$Temp.dataSet)


}

End {

Return $Result

}

}

Function Get-TopdeskAMAssetFiles {

<#

.SYNOPSIS
Retrieves list of uploaded blobs (attachments) of the given selector, e.g. asset

.DESCRIPTION
Retrieves list of uploaded blobs (attachments) of the given selector, e.g. asset

.PARAMETER URL
Base TOPdesk URL (e.g., https://customer.topdesk.net).

.PARAMETER Username
API username used for authentication.

.PARAMETER ApplicationPassword
API application password for Basic Authentication.

.PARAMETER AssetId
The ID of the asset, which contains the files

.EXAMPLE
PS C:\> ...

.NOTES
Author : Rico Roodenburg
Author email : r.roodenburg@syntrophos.nl
Version : 1.0

===Tested Against Environment====
TOPdesk API version : 1.49.1
PowerShell Version : 5.1

#>

Param (

[Parameter(Position=0, Mandatory = $true)]
[string]$URL,

[Parameter(Position=1, Mandatory = $true)]
[string]$Username,

[Parameter(Position=2, Mandatory = $true)]
[string]$ApplicationPassword,

[Parameter(Position=3, Mandatory = $true)]
[string]$Assetid

)

Begin {

$Headers = @{

Authorization = "Basic " + [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes("$($Username):$($ApplicationPassword)"))

}
}

Process {


Try {

$Result = Invoke-RestMethod -Uri "$URL/tas/api/assetmgmt/uploads?assetId=$($assetId)" -Headers $Headers -Method Get -ContentType "application/json" -ErrorAction Stop

} Catch {

# Error...
Write-Debug (">> Error while getting the uploaded blobs of the asset $assetId within TOPdesk, see error code below..")
Write-Debug ("StatusCode:" + $_.Exception.Response.StatusCode.value__ )
Write-Debug ("StatusDescription:" + $_.Exception.Response.StatusDescription)
Write-Debug ("Error: " + $_.ErrorDetails.Message)

}

}

End {

Return $Result.dataSet

}

}

Function Download-TopdeskAMAssetFile {

<#

.SYNOPSIS
Downloads a file from TOPdesk Asset Management using Basic Authentication.

.DESCRIPTION
This function retrieves a file from a TOPdesk environment using the provided
URL, file path, and Basic Auth credentials. The downloaded file will be saved
to the specified output folder. If errors occur, detailed debug output
is written for troubleshooting.

.PARAMETER URL
Base TOPdesk URL (e.g., https://customer.topdesk.net).

.PARAMETER Username
API username used for authentication.

.PARAMETER ApplicationPassword
API application password for Basic Authentication.

.PARAMETER FilePath
The path to the file within TOPdesk (e.g., /tas/api/files/...).

.PARAMETER OutPath
The local output folder where the file should be saved.

.PARAMETER FileName
Filename to use for the downloaded file (e.g., "document.pdf").

.EXAMPLE
PS> Download-TopdeskAMAssetFile -URL "https://customer.topdesk.net" -Username "api-user" -ApplicationPassword "ApplicationPassword" -FilePath "/tas/api/files/12345/download" -OutPath "C:\Temp\Asset Management\Files" -FileName "assetfile.pdf"
Downloads the file with ID 12345 from TOPdesk and saves it locally as
'assetfile.pdf' in the specified folder.

.NOTES
Author : Rico Roodenburg
Author email : r.roodenburg@syntrophos.nl
Version : 1.0

===Tested Against Environment====
TOPdesk API version : 1.91.1
PowerShell Version : 5.1

#>


Param (

[Parameter(Position=0, Mandatory = $true)]
[string]$URL,

[Parameter(Position=1, Mandatory = $true)]
[string]$Username,

[Parameter(Position=2, Mandatory = $true)]
[string]$ApplicationPassword,

[Parameter(Position=3, Mandatory = $true)]
[string]$FilePath,

[Parameter(Position=4, Mandatory = $true)]
[string]$OutPath,

[Parameter(Position=5, Mandatory = $true)]
[string]$FileName

)

Begin {

$Headers = @{

Authorization = "Basic " + [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes("$($Username):$($ApplicationPassword)"))

}
}

Process {


Try {

Invoke-WebRequest -Uri "$($URL)$($FilePath)" -OutFile "$($OutPath)\$($FileName)" -Headers $Headers

} Catch {

# Error...
Write-Debug (">> Error while downloading the uploaded blob ($FileName), see error code below..")
Write-Debug $_

}

}

}

# -------------------------
# Variables
# -------------------------

# TOPdesk URL
$TOPdeskURL = "https://customer.topdesk.net"

# TOPdesk Username
$Username = ""

# TOPdesk Application Password
$ApplicationPassword = ""

# Multiple template names possible:
# - For multiple: @("template1", "template2", "template3")
# - For single: @("template1")
$TemplateNames = @("template1","template2","template3")

# Output folder for downloaded files.
# If the folder does not exist, the script will create it.
$DownloadFolder = "C:\Temp\Asset Management\Files"

# -------------------------
# END region Variables – do not change anything below
# -------------------------

# Check if path exists
If (-not (Test-Path $DownloadFolder)){

New-Item -Path $DownloadFolder -ItemType Directory -Force | Out-Null

}

# Get Assets
$Assets = Get-TopdeskAMAssets -URL $TOPdeskURL -Username $Username -ApplicationPassword $ApplicationPassword -templateNames $TemplateNames

# Iterate through assets
Foreach ($Asset in $Assets){

# Get list of files linked to assets
$Files = Get-TopdeskAMAssetFiles -URL $TOPdeskURL -Username $Username -ApplicationPassword $ApplicationPassword -Assetid $Asset.unid

Foreach ($File in $Files){

# Download file
Write-Host "Download file $($File.Name) to folder $($DownloadFolder)\$($Asset.Name)" -ForegroundColor Cyan
New-Item "$($DownloadFolder)\$($Asset.Name)" -ItemType Directory -Force | Out-Null
Download-TopdeskAMAssetFile -URL $TOPdeskURL -Username $Username -ApplicationPassword $ApplicationPassword -FilePath $File.Url -OutPath "$($DownloadFolder)\$($Asset.Name)" -FileName $File.Name

}

$Files = $null

}