This PowerShell Module is a wrapper for the ADB REST api.
-
Connect-AdbServer
Login to the adb server. The session is stored in the module context and is returned as a session object if required. -
Disconnect-AdbServer
Logout from the adb server. Clear the session in the module context. -
Get-AdbResource
Generic command to get an adb documents. -
Set-AdbResource
Update an existing adb resource. -
New-AdbResource
Create a new adb resource. -
Remove-AdbResource
Generic command to remove adb documents. -
Get-AdbUser
Get the current adb user. -
Get-AdbItem
Get an item from the adb. -
Test-AdbItemValidation
Test an item against a template schema.
A session can be created by providing credentials, passing a token or requesting
access from an active user. By omitting any login information and using the
-Guest
parameter, access is limited to guest information.
# Connect to the adb server by using username and password
Connect-AdbServer -Uri 'https://adb.contoso.com' -Credential 'john'
# Connect to the adb server by using an existing token
Connect-AdbServer -Uri 'https://adb.contoso.com' -Token 'XXX'
# Request access from the user john
Connect-AdbServer -Uri 'https://adb.contoso.com' -UserRequest 'john'
# Access the adb as a guest user
Connect-AdbServer -Uri 'https://adb.contoso.com' -Guest
# Store the adb session in a variable
$adbSession = Connect-AdbServer -Uri 'https://adb.contoso.com' -Credential 'john' -PassThru
# Get the current adb session
$adbSession = Get-AdbSession
# Logoff from the session stored in the module context
Disconnect-AdbServer
# Logoff from the specified session.
Disconnect-AdbServer -Session $adbSession
Get the current logged in adb user.
# Query own adb user
Get-AdbUser
Query some adb resources, e.g. templates, items.
# Query 3 templates
$templates = Get-AdbResource -Type 'Template' -Limit 3
$templates.Name
# Query new item
$item = Get-AdbItem -Name 'myitem'
# this does the same
$item = Get-AdbResource -Type 'Item' -Name 'myitem'
Save a new item to the adb.
# Prepare a new item
$item = @{
name = 'test_item'
properties = @{
hostname = 'test'
vc_username = 'test'
}
}
# Save new item to adb
$item | New-AdbResource -Type 'Item'
Update an item in the adb.
$item = Get-AdbItem -Name 'myitem'
# Prepare updated item (add/remove properties)
$item.properties | Add-Member 'net_ipadress' '10.1.2.3'
$item.properties.PSObject.properties.Remove("vc_username")
# Save the updated item
$item | Set-AdbResource
Validate an item against a role schema:
Test-AdbItemValidation -Template 'mytemplate' -Name 'myitem'
Please find all versions in the GitHub Releases section and the release notes in the CHANGELOG.md file.
Use the following command to install the module from the PowerShell Gallery, if the PackageManagement and PowerShellGet modules are available:
# Download and install the module
Install-Module -Name 'PSAdb'
Alternatively, download the latest release from GitHub and install the module manually on your local system:
- Download the latest release from GitHub as a ZIP file: GitHub Releases
- Extract the module and install it: Installing a PowerShell Module
The following minimum requirements are necessary to use this module, or in other words are used to test this module:
- Windows PowerShell 5.1
- Windows Server 2012 R2
Please feel free to contribute by opening new issues or providing pull requests. For the best development experience, open this project as a folder in Visual Studio Code and ensure that the PowerShell extension is installed.
- Visual Studio Code with the PowerShell Extension
- Pester, PSScriptAnalyzer and psake PowerShell Modules