
pmx1v (pmx1v) asked a question.
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"

Hi @pmx1v (pmx1v) , Thank you for reaching out to the Okta Community. Have you tried this?
https://toolkit.okta.com/apps/okta-psmodule/
Maybe it will help you get the list of apps.