<iframe src="https://www.googletagmanager.com/ns.html?id=GTM-M74D8PB" height="0" width="0" style="display:none;visibility:hidden">
Loading
Skip to NavigationSkip to Main Content
0D54z00007XrjCZCAZOkta Classic EngineAdministrationAnswered2025-02-02T09:02:27.000Z2022-03-30T12:27:35.000Z2022-03-31T16:21:47.000Z

pmx1v (pmx1v) asked a question.

Powershell Script to get a list of applications from OKTA

Hi,

 

I am new to powershell and I tried to build from different scripts the following script to get a list of applications from OKTA. I can get the csv file with the titles but its not returning any data back. Can you please help me to find out what is wrong with the script? I have removed the sensitive information such as url and token.

 

* Use TLS 1.2

[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12

 

* Setup Auth Header

$header = @{

  Authorization = "SSWS "

}

 

* API Resource Endpoint

$url = "url.com/api/v1/apps"

 

$Apps = @()

 

do {

  $result = Invoke-WebRequest -Uri $url -Headers $header -UseBasicParsing

  $json = $result.Content | convertfrom-json

  $Apps += $json

  $next = $next = ((($result.headers.link -split ",")[1] -split ";")[0] -replace "<", "") -replace ">", ""

  $url = $next

 

}

while ($result.Headers.Link -match "next")

 

$Apps | Foreach-object {

   

  [pscustomobject]@{

  id = $app.id  

  Type = $app.name

  label = $app.label  

  lastUpdated = $app.lastUpdated

  created = $app.created

  signOnMode = $app.signOnMode

  usernametemplate = $app.credentials.userNameTemplate.template

  usernametype = $app.credentials.userNameTemplate.type

  username = $app.credentials.userNameTemplate

  BookmarkURL = $app.settings.app.url

  EmbeddedLink = $app._links.appLinks.href

  Status = $app.status

  Error = if ($_ -eq $null){"Something wrong"}else{}

  }

} | Export-Csv ./x.csv -Force

 

*Write-Output "($Apps).count:OK"


This question is closed.
Loading
Powershell Script to get a list of applications from OKTA