Celerium.DattoBCDR
Buy me a coffee
Whether you use this project, have learned something from it, or just like it, please consider supporting it by buying me a coffee, so I can dedicate more time on open-source projects like this :)
About The Project
The Celerium.DattoBCDR offers users the ability to extract data from Datto into third-party reporting tools and aims to abstract away the details of interacting with Datto’s API endpoints in such a way that is consistent with PowerShell nomenclature. This gives system administrators and PowerShell developers a convenient and familiar way of using Datto’s API to create documentation scripts, automation, and integrations.
- :book: Project documentation can be found on Github Pages
- :book: Datto’s REST API documentation on their management portal here [ Requires a login ].
Datto features a REST API that makes use of common HTTP request methods. In order to maintain PowerShell best practices, only approved verbs are used.
- GET ->
Get- - PUT ->
Set-
Additionally, PowerShell’s verb-noun nomenclature is respected. Each noun is prefixed with Datto in an attempt to prevent naming problems.
For example, one might access the /bcdr/device endpoint by running the following PowerShell command with the appropriate parameters:
Get-DattoBCDRDevice -SerialNumber 12345
Install
This module can be installed directly from the PowerShell Gallery with the following command:
Install-Module -Name Celerium.DattoBCDR
- :information_source: This module supports PowerShell 5.0+ and should work in PowerShell Core.
- :information_source: If you are running an older version of PowerShell, or if PowerShellGet is unavailable, you can manually download the main branch and place the Celerium.DattoBCDR folder into the (default)
C:\Program Files\WindowsPowerShell\Modulesfolder.
Project documentation can be found on Github Pages
- A full list of functions can be retrieved by running
Get-Command -Module Celerium.DattoBCDR. - Help info and a list of parameters can be found by running
Get-Help <command name>, such as:
Get-Help Get-DattoBCDRDevice
Get-Help Get-DattoBCDRDevice -Full
Initial Setup
After installing this module, you will need to configure the API access tokens that are used to talk with the Datto API.
- Run
Add-DattoBCDRAPIKey -ApiKeyPublic 12345 -ApiKeySecret 123456789- It will prompt you to enter your API access tokens if you do not specify them.
- Datto API access tokens are generated via the Datto portal at Admin > Integrations
- [optional] Run
Export-DattoBCDRModuleSettings- This will create a config file at
%UserProfile%\Celerium.DattoBCDRthat holds the base uri & API access tokens information. - Next time you run
Import-Module -Name Celerium.DattoBCDR, this configuration file will automatically be loaded. - :warning: Exporting module settings encrypts your API access tokens in a format that can only be unencrypted by the user principal that encrypted the secret. It makes use of .NET DPAPI, which for Windows uses reversible encrypted tied to your user principal. This means that you cannot copy your configuration file to another computer or user account and expect it to work.
- :warning: However in Linux\Unix operating systems the secret keys are more obfuscated than encrypted so it is recommend to use a more secure & cross-platform storage method.
- This will create a config file at
Usage
Calling an API resource is as simple as running Get-DattoBCDR<resourceName>
- The following is a table of supported functions and their corresponding API resources:
- Example scripts can be found in the examples folder of this repository.
| Category | EndpointUri | Method | Function |
|---|---|---|---|
| BCDR | /bcdr/agent | GET | Get-DattoBCDRAgent |
| BCDR | /bcdr/device | GET | Get-DattoBCDRDevice |
| BCDR | /bcdr/device/{serialNumber} | GET | Get-DattoBCDRDevice |
| BCDR | /bcdr/device/{serialNumber}/alert | GET | Get-DattoBCDRAlert |
| BCDR | /bcdr/device/{serialNumber}/asset | GET | Get-DattoBCDRAsset |
| BCDR | /bcdr/device/{serialNumber}/asset/{volumeName} | GET | Get-DattoBCDRVolume |
| BCDR | /bcdr/device/{serialNumber}/asset/agent | GET | Get-DattoBCDRAgent |
| BCDR | /bcdr/device/{serialNumber}/asset/share | GET | Get-DattoBCDRShare |
| BCDR | /bcdr/device/{serialNumber}/vm-restores | GET | Get-DattoBCDRVMRestore |
| DTC | /dtc/{clientId}/assets | GET | Get-DattoBCDRDTCAsset |
| DTC | /dtc/{clientId}/assets/{assetUuid} | GET | Get-DattoBCDRDTCAsset |
| DTC | /dtc/agent/{agentUuid}/bandwidth | PUT | Set-DattoBCDRDTCBandwidth |
| DTC | /dtc/assets | GET | Get-DattoBCDRDTCAsset |
| DTC | /dtc/rmm-templates | GET | Get-DattoBCDRDTCRMMTemplate |
| DTC | /dtc/storage-pool | GET | Get-DattoBCDRDTCStoragePool |
| Reporting | /report/activity-log | GET | Get-DattoBCDRActivityLog |
| SaaS | /saas/{SaasCustomerId}/{externalSubscriptionId}/bulkSeatChange | PUT | Set-DattoBCDRSaaSBulkSeatChange |
| SaaS | /saas/{sassCustomerId}/detailedBackupStats | GET | Get-DattoBCDRSaaSBackupStats |
| SaaS | /sass/{sassCustomerId}/applications | GET | Get-DattoBCDRSaaSApplication |
| SaaS | /sass/{sassCustomerId}/seats | GET | Get-DattoBCDRSaaSSeat |
| SaaS | /sass/domains | GET | Get-DattoBCDRSaaSDomain |
Each Get-DattoBCDR* function will respond with the raw data that Datto’s API provides.
- :warning: Returned data is mostly structured the same but can vary between commands.
- pagination - Information about the number of pages of results are available and other metadata.
- items - The actual information requested (this is what most people care about)
Contributing
Contributions are what makes the open-source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag “enhancement”. Don’t forget to give the project a star! Thanks again!
See the CONTRIBUTING guide for more information about contributing.
License
Distributed under the MIT license. See LICENSE for more information.