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 :)
The DattoAPI 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.
- 📖 Project documentation can be found on Github Pages
- 📖 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-DattoDevice -serialNumber 12345
This module can be installed directly from the PowerShell Gallery with the following command:
Install-Module -Name DattoAPI
- ℹ️ This module supports PowerShell 5.0 and should work in PowerShell Core.
- ℹ️ If you are running an older version of PowerShell, or if PowerShellGet is unavailable, you can manually download the main branch and place the DattoAPI folder into the (default)
C:\Program Files\WindowsPowerShell\Modules
folder.
Project documentation can be found on Github Pages
- A full list of functions can be retrieved by running
Get-Command -Module DattoAPI
. - Help info and a list of parameters can be found by running
Get-Help <command name>
, such as:
Get-Help Get-DattoDevice
Get-Help Get-DattoDevice -Full
After installing this module, you will need to configure both the base URI & API access tokens that are used to talk with the Datto API.
-
Run
Add-DattoBaseURI
- By default, Datto's
https://api.datto.com/v1
URI is used. - If you have your own API gateway or proxy, you may put in your own custom URI by specifying the
-base_uri
parameter:Add-DattoBaseURI -base_uri http://myapi.gateway.celerium.org
- By default, Datto's
-
Run
Add-DattoAPIKey -Api_Key_Public 12345 -Api_Key_Secret 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-DattoModuleSettings
- This will create a config file at
%UserProfile%\DattoAPI
that holds the base uri & API access tokens information. - Next time you run
Import-Module -Name DattoAPI
, this configuration file will automatically be loaded. ⚠️ 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.⚠️ 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
Calling an API resource is as simple as running Get-Datto<resourceName>
- The following is a table of supported functions and their corresponding API resources:
- Table entries with [
-
] indicate that the functionality is NOT supported by the Datto API at this time.
Section | API Resource | Create | Read | Update | Delete |
---|---|---|---|---|---|
Reporting | ActivityLog | - | Get-DattoActivityLog |
- | - |
BCDR | Agent | - | Get-DattoAgent |
- | - |
BCDR | Alert | - | Get-DattoAlert |
- | - |
BCDR | Asset | - | Get-DattoAsset |
- | - |
BCDR | BCDR * | - | Get-DattoBCDR |
- | - |
BCDR | Device | - | Get-DattoDevice |
- | - |
BCDR | Share | - | Get-DattoShare |
- | - |
BCDR | VMRestore | - | Get-DattoVMRestore |
- | - |
BCDR | Volume | - | Get-DattoVolume |
- | - |
SaaS | SaaS * | - | Get-DattoSaaS |
- | - |
SaaS | Domains | - | Get-DattoDomain |
- | - |
SaaS | Seats | - | Get-DattoSeat |
- | - |
SaaS | Applications | - | Get-DattoApplication |
- | - |
SaaS | BulkSeatChange | - | - | Set-DattoBulkSeatChange |
- |
⚠️ Get-DattoBCDR
&Get-DattoSaaS
are special functions.- These are NOT endpoints in Datto's REST API and are a single set of commands that can run endpoints in their associate sections.
- I included them because they made scripting easier and felt like a nice-to-have feature IMO
Each Get-Datto*
function will respond with the raw data that Datto's API provides.
⚠️ 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)
- Add Changelog
- Build more robust Pester & ScriptAnalyzer tests
- Figure out how to do CI & PowerShell gallery automation
- Add example scripts & automation
See the open issues for a full list of proposed features (and known issues).
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.
Distributed under the MIT License. See LICENSE
for more information.
Big thank you to the following people and services as they have provided me with lots of helpful information as I continue this project!