PS C:\Blog\rksolutions> cd ..

InforcerCommunity: A PowerShell Module for the Inforcer REST API

· 8 min read · Roy Klooster
Conditional Access Exchange Online Entra ID Intune Reports Tools

If you use Inforcer to manage Microsoft 365 baselines, alignment scores, and policies across tenants, you already know the value of a single pane of glass for compliance and policy drift. But automation and scripting often mean wrestling with REST APIs, building your own auth and error handling, and maintaining scripts that break when the API changes. InforcerCommunity is a community PowerShell module that wraps the Inforcer API so you can connect, query tenants, baselines, policies, alignment scores, and audit events from the command line or from your own scripts - with consistent parameters, sensible defaults, and help that works. This guide explains what it does, how to use it, and how you can contribute or ask for new features.

Table of Contents

What is InforcerCommunity?

InforcerCommunity is a PowerShell script module that talks to the Inforcer REST API.

What it gives you:

  • Connect once, query everything: Authenticate with your Inforcer API key and region, then run cmdlets to list tenants, baselines, policies, alignment scores, and audit events.
  • Consistent behavior: All Get-* cmdlets support -Format-OutputType (PowerShellObject or JsonObject), and - where it applies -TenantId for filtering.
  • No secrets in scripts: The API key is stored as a SecureString in the session; you can pass it once via Connect-Inforcer and then run as many commands as you need.
  • Tab completion and help: Every cmdlet has comment-based help; Get-Help Connect-Inforcer -Full and tab completion on parameters (e.g. -EventType on Get-InforcerAuditEvent) work out of the box.

Where to find it:

Community project notice: InforcerCommunity was created by me for the community. It is not owned, endorsed, or maintained by Inforcer. It is an independent, community-driven project to make the Inforcer API easier to use from PowerShell. You use it at your own responsibility.

Requirements

  • PowerShell 7.0 or later (Windows, macOS, or Linux).
  • An Inforcer API key from your Inforcer tenant (Configure > REST API > New API Key).

Installation

Install-Module -Name InforcerCommunity -Scope CurrentUser

Option 2: From source (GitHub)

git clone https://github.com/royklo/InforcerCommunity.git
cd InforcerCommunity
Import-Module ./module/InforcerCommunity.psd1 -Force

Important: When loading from source, always run Import-Module from the repository root and use the path ./module/InforcerCommunity.psd1. If you see errors about a missing file or wrong path, make sure you are in the InforcerCommunity repo root.

Quick Start

After installing the module:

# Connect with your API key (region: uk, eu, us, or anz)
Connect-Inforcer -ApiKey "your-api-key" -Region uk

# List all tenants you have access to
Get-InforcerTenant

# Get alignment scores in table format
Get-InforcerAlignmentScore

# Get policies for a specific tenant (by Client Tenant ID)
Get-InforcerTenantPolicies -TenantId 482

# Disconnect when done
Disconnect-Inforcer

You can use Get-Help <CmdletName> -Full for parameters and examples (e.g. Get-Help Get-InforcerTenant -Full).

Key Cmdlets and Use Cases

Cmdlet What it does
Connect-Inforcer Establishes a secure connection to the Inforcer API (ApiKey, Region or BaseUrl).
Disconnect-Inforcer Clears the session and disconnects.
Test-InforcerConnection Verifies the current API connection.
Get-InforcerTenant Lists tenants; optional -TenantId to return a single tenant.
Get-InforcerBaseline Retrieves baseline groups and members.
Get-InforcerTenantPolicies Retrieves policies for a given tenant.
Get-InforcerAlignmentScore Retrieves alignment scores (table or raw; optional -TenantId, -Tag).
Get-InforcerAuditEvent Retrieves audit events (optional -EventType, date range, paging).

Typical workflows:

  • Tenant and policy overview: Connect-Inforcer → Get-InforcerTenant → Get-InforcerTenantPolicies -TenantId <id> to inspect a specific tenant’s policies.
  • Alignment and drift: Get-InforcerAlignmentScore for scores; Get-InforcerTenant | Select-Object ClientTenantId, TenantFriendlyName, PolicyDiffFormatted to see policy change summaries.
  • Audit and compliance: Get-InforcerAuditEvent with optional -EventType (tab completion for event types), -DateFrom-DateTo, and paging parameters.

For full parameter details and example output, see the Cmdlet Reference in the repository.

Output Formats and Filtering

  • -Format: Most Get-* cmdlets support Table or Raw (e.g. for alignment scores).
  • -OutputType: PowerShellObject (default) or JsonObject (JSON with depth 100) for piping into other tools or export.
  • -TenantId: Where applicable (e.g. Get-InforcerTenantGet-InforcerTenantPoliciesGet-InforcerAlignmentScore), use -TenantId to limit results to one tenant.
# Example: export all tenants as JSON for use elsewhere
Get-InforcerTenant -OutputType JsonObject | Out-File tenants.json -Encoding utf8

How to Contribute

Contributions are welcome. The project uses a standard fork-and-pull-request workflow:

  • Fork the repository on GitHub: https://github.com/royklo/InforcerCommunity.
  • Clone your fork and create a branch (e.g. feature/your-feature-name or fix/bug-description).
  • Make your changes under module/ (see CONTRIBUTING.md for code style and the consistency contract - parameter order, -Format/-OutputType, property names, etc.).
  • Run tests from the repo root: Invoke-Pester ./Tests/Consistency.Tests.ps1.
  • Commit and push to your fork, then open a pull request against the main repository. Fill in the PR template (summary, how to test, related issue if any).

New cmdlets must be added to module/Public/, registered in FunctionsToExport in the manifest, and documented in docs/CMDLET-REFERENCE.md. The consistency tests must be updated if you add or change exported cmdlets or key parameters.

How to Report Bugs

If something doesn’t work as expected:

  • Go to New issue.
  • Choose Bug report.
  • Fill in:

Description: What went wrong?

  • Steps to reproduce: Exact commands or steps.
  • Expected behavior: What you expected.
  • Actual behavior: What happened instead (including any error messages).
  • Environment: PowerShell version, OS, and module version (e.g. Get-Module InforcerCommunity | Select-Object Version).
  • Additional context: Logs, screenshots, or other details.

This helps maintainers and the community reproduce and fix issues quickly.

How to Request a Feature

Have an idea for a new cmdlet, parameter, or behaviour?

  • Go to New issue.
  • Choose Feature request.
  • Describe:

The feature you’d like (e.g. a new endpoint, a new parameter, or a different output shape).

  • The use case (why it would help you or others).
  • If you have one, a proposed solution (e.g. cmdlet name, parameters, example usage).

Not every request can be implemented immediately, but all are read and considered; they also help others discover and discuss ideas.

Conclusion

InforcerCommunity turns the Inforcer API into a set of PowerShell cmdlets you can use interactively or in scripts: connect once, then list tenants, baselines, policies, alignment scores, and audit events with consistent parameters and output. It’s a community project, not owned or maintained by Inforcer; feedback, bug reports, and feature requests from users like you shape what comes next. Install it from the PowerShell Gallery, try the quick start, and if you hit a bug or have an idea, open an issue or send a pull request.

back to all posts next: RKSolutions PowerShell Module
PS Select-String -Pattern
↑↓navigate open escclose