Using Powershell with the Okta API Skip to main content
How satisfied are you with the Okta Help Center?
Thank you for your feedback!
How satisfied are you with the Okta Help Center?
Very Dissatisfied
Very satisfied
Enter content less than 200 characters.
Ask Search:
Keith WorkKeith Work 

Using Powershell with the Okta API

We have a few dozen 3rd party web sites that we use for various things and for some of them we have an ID for each of our branches (and we open new branches frequently), others use an ID for each employee, others use an ID for everyone to share. I'd like to automate the creation of these apps for the new offices we open using PowerShell. Is that possible with the API? If so, are there examples anywhere?

Gabriel SrokaGabriel Sroka (Okta, Inc.)
Hi Keith
I'm not sure what your exact use case is. Can you work thru the steps? eg:
1. create a new app
2. assign a user to the app

Also, see Okta Developer Docs:

And Unofficial PowerShell Modules:


Gabriel Sroka
Keith WorkKeith Work
Yeah thanks Gabriel. Basically suppose I have an account set up with Office Depot for each of my offices (300 of them). Each has an ID like "MyOffice1", "MyOffice2", etc and their own password to login to and order supplies. I open new offices at the rate of 1 a week and I'd like to automate the process of creating Okta "apps" for each office when they open. So "MyOffice301" will need a new app set up with their unique credentials and assigned to members of an AD group I've populated.

I'd like to do that with 50 different apps for each restaurant. So it'll need to be scripted somehow. That make sense?

Or, to boil it down, how do I create apps in Okta with PowerShell? The developer site doesn;t seem to have any resources for that...

Gabriel SrokaGabriel Sroka (Okta, Inc.)
Hi Keith
You can create apps in Okta with PowerShell.

This page shows you how to do it from the API:

So you should be able to translate that into PowerShell using one of the resources I mentioned in my reply above.

Do you need a unique OfficeDepot app for each office (ie 300 apps)? Or 1 app with 300 users assigned to it? Answering this question will help you decide which APIs you need to call.
Keith WorkKeith Work
We have a mix of sites we use:
  • For those that use individual user-based logins, they can have a single app and maintain their own log in for it.
  • For those that have a login for their office (the most common scenario), we want them to be automatically authenticated without knowing the credentials so I assume that means 1 app per office, per web site, right?
  • For those with a common shared login, we can set up a single app and all users can be assigned to it.
That sound like a plan? Thanks.
Keith WorkKeith Work
Oh and I was hoping you might have an example of the PowerShell to use your APIs - it must be a common thing for admins to do right?
Gabriel SrokaGabriel Sroka (Okta, Inc.)
Hi Keith 
I added an example of creating a SWA app and assigning a user to it. I hope that helps get you started. Please see:

I modified OktaAPI.psm1 to include New-OktaApp and Add-OktaAppUser and added a sample in CallOktaAPI.ps1:
function Add-SwaApp() {
    $me = Get-OktaUser "me"
    # see
    $app = @{label = "AAA Test App"; 
        settings = @{signOn = @{loginUrl = ""}};
        signOnMode = "AUTO_LOGIN"; visibility = @{autoSubmitToolbar = $false}}
    $app = New-OktaApp $app

    # see
    $appuser = @{id = $; scope = "USER"}
    Add-OktaAppUser $ $appuser
Keith WorkKeith Work
Thanks Gabriel! You are a life saver!
Keith WorkKeith Work
Oh have you published this to the PowerShell Gallery? So I can install it from the console? Looks like 1.07 was published January 22.
Gabriel SrokaGabriel Sroka (Okta, Inc.)
Hi Keith
I just published it now. In case I don't publish future changes on, you can find them on: