![]() |
VOOZH | about |
The CData Cmdlets for Okta are standard PowerShell cmdlets that make it easy to accomplish data cleansing, normalization, backup, and other integration tasks by enabling real-time access to Okta.
The Cmdlets are not only a PowerShell interface to Okta, but also an SQL interface; this tutorial shows how to use both to retrieve Okta data. We also show examples of the ADO.NET equivalent, which is possible with the CData ADO.NET Provider for Okta. To access Okta data from other .NET applications, like LINQPad, use the CData ADO.NET Provider for Okta.
Once you have acquired the necessary connection properties, accessing Okta data in PowerShell can be enabled in three steps.
To connect to Okta, set the Domain connection string property to your Okta domain.
You will use OAuth to authenticate with Okta, so you need to create a custom OAuth application.
From your Okta account:
Install the module:
Install-Module OktaCmdlets
Connect:
$okta = Connect-Okta -Domain "$Domain" -InitiateOAuth "$InitiateOAuth"
Search for and retrieve data:
$status = "Active" $users = Select-Okta -Connection $okta -Table "Users" -Where "Status = `'$Status`'" $users
You can also use the Invoke-Okta cmdlet to execute SQL commands:
$users = Invoke-Okta -Connection $okta -Query 'SELECT * FROM Users WHERE Status = @Status' -Params @{'@Status'='Active'}
Load the provider's assembly:
[Reflection.Assembly]::LoadFile("C:\Program Files\CData\CData ADO.NET Provider for Okta\lib\System.Data.CData.Okta.dll")
Connect to Okta:
$conn= New-Object System.Data.CData.Okta.OktaConnection("Domain=dev-44876464.okta.com;InitiateOAuth=GETANDREFRESH;")
$conn.Open()
Instantiate the OktaDataAdapter, execute an SQL query, and output the results:
$sql="SELECT Id, ProfileFirstName from Users"
$da= New-Object System.Data.CData.Okta.OktaDataAdapter($sql, $conn)
$dt= New-Object System.Data.DataTable
$da.Fill($dt)
$dt.Rows | foreach {
Write-Host $_.id $_.profilefirstname
}
Download a free trial of the Okta Data Provider to get started:
Download NowLearn more:
👁 Okta IconRapidly create and deploy powerful .NET applications that integrate with Okta.