Skip to content

colombeen/AdminByRequest

Repository files navigation

Admin By Request PowerShell module

GitHub Release PowershellGallery GalleryVersion GitHub commit activity (branch) GitHub License

Admin by Request PowerShell module

Introduction

This repository contains a full Windows PowerShell/Powershell Core module with functions that help you interact with the Admin by Request APIs. API information can be found on https://www.adminbyrequest.com/docs/api-overview

Requirements

Requirement Version
Windows PowerShell 5.1+
PowerShell Core 6.0+

Installation

The module is available on the PowerShell gallery.

PS C:\> # Install the module
PS C:\> Install-Module -Name 'AdminByRequest'

How to use

PowerShell supports autloading of modules so normally you shouldn't need to import the module manually, I just include it to be thorough.

PS C:\> # Import the module
PS C:\> Import-Module -Name 'AdminByRequest'

The first thing that is needed at this point is setting up the connection information. 2 out of the 3 parameters are required:

  • APIKey
  • Region

You are able add the UserMail param if you want the audit logs to reflect which user has approved/denied a request.

PS C:\> # Setup the connection information
PS C:\> Set-ABRConnection -APIKey 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx' -Region 'EU' -UserMail '[email protected]'

At this point you should be able to use any of the available functions to interact with the API.

Auditlog

PS C:\> # Get a list with audit logs
PS C:\> Get-ABRAuditlog | Format-Table

installs        uninstalls      elevatedApplications scanResults id
--------        ----------      -------------------- ----------- --
{}              {@{applicati... {@{name=Microsoft... {}          123456
{@{applicati... {}              {@{name=Microsoft... {}          123457
{}              {}              {@{name=Microsoft... {}          123458
...

Events

PS C:\> # Get a list with events
PS C:\> Get-ABREvent | Format-Table

      id eventCode eventLevel eventText                              eventTime
      -- --------- ---------- ---------                              ---------
12345678         6          1 Unaudited administrator logged on      2023-01-...
12345679        40          0 Admin By Request Workstation installed 2023-02-...
12345680         5          0 Audited administrator logged on        2023-03-...
...

PS C:\> # Get a list with all event codes and their text values
PS C:\> Get-ABREventCode | Format-Table

EventCode EventText
--------- ---------
1         User added to local admins group
2         User downgraded from administrator to user
...

Inventory

PS C:\> # Get a list with inventory computers
PS C:\> Get-ABRInventory | Format-Table

id        name      inventoryAvailable InventoryDate       abrClientVersion
--        ----      ------------------ -------------       ----------------
123456    Computer1               True 01/02/2023 00:00:00 8.0.1
123457    Computer2               True 02/03/2023 00:00:00 8.0.1
...

Requests

PS C:\> # Get a list with requests
PS C:\> Get-ABRRequest | Format-Table

scanResults     id traceNo   type         status  application
-----------     -- -------   ----         ------  -----------
{}          123456 123456789 Run As Admin Pending @{file=wt.exe;...
{}          123457 123456790 Run As Admin Denied  @{file=wt.exe;...
...

PS C:\> # Approve a specific request
PS C:\> Approve-ABRRequest -Id 123456

PS C:\> # Check the status for the approved request
PS C:\> Get-ABRRequest -Id 123456 | Format-Table
scanResults     id traceNo   type         status  application
-----------     -- -------   ----         ------  -----------
{}          123456 123456789 Run As Admin Aproved @{file=wt.exe;...

PS C:\> # Deny a specific request
PS C:\> Deny-ABRRequest -Id 123457 -Reason 'Not allowed by our company policy'

PIN codes

PS C:\> # Request an uninstall PIN for a specific device by using the Inventory Id
PS C:\> Request-ABRPinCodeForUninstall -Id 123456
9876543210

PS C:\> # Request an elevation PIN for a specific device by using the ComputerName
PS C:\> Request-ABRPinCodeForElevation -ComputerName Computer1 -Pin1 000000
9876543210

Who Am I

PS C:\> # Get a list with information on the current tenant
PS C:\> Get-ABRWhoAmI

tenantName            : Company
apiUrl                : https://dc1api.adminbyrequest.com
workstationSeats      : 987
workstationUsage      : 123
workstationExpiryDate : 2025-01-01T00:00:00
serverSeats           : 654
serverUsage           : 456
serverExpiryDate      : 2025-01-01T00:00:00

ToDo

  • I still need to create Pester tests.
  • I've tried to add pipeline support to the best of my knowledge but I haven't tested everything yet...