Okta Powershell

How to Connect to Okta Powershell

TECH

2/27/20241 min read

How to Connect to Okta using PowerShell

This guide will walk you through the steps to seamlessly connect to Okta admin via PowerShell and leverage administration management. It can be run on Windows PowerShell or cross-platform on PowerShell Core, supporting Windows, Mac, and Linux.

Getting Started

1.     Install and Import the Module

  • Open a PowerShell console and run Install-Module Okta. Confirm the installation when prompted. Once installed, import the module with Import-Module Okta.

2.     Create an Okta API Token

  • To make calls against the Okta API, generate an API token in the Okta administrator console. Instructions can be found here.

3.     Connect to the Okta Org

  • Run the following command, replacing placeholders with the Okta domain and API token: Connect-Okta -OktaDomain https://domainhere.okta.com -ApiToken "apitokenhere"

4.     You should now be able to run Okta PowerShell commands.

 Sample Okta PowerShell Commands:

  • Get a user by identifier: Get-OktaUser -Identity test.useraccount

  • Get users with a filter: Get-OktaUser -Filter 'status eq "ACTIVE"'

  • Get apps: Get-OktaApp -All

  • Get groups: Get-OktaUser -Identity "test.useraccount" | Get-OktaGroup

  • Get system event logs: Get-OktaLogEvent -StartDate 2/27/2024

Additional Commands

  • Explore and manage groups, roles, events, and more by running: Get-Command -Module Okta.