Automate ADP Integration Tasks from PowerShell

Jerod Johnson
Jerod Johnson
Director, Technology Evangelism
Are you in search of a quick and easy way to access ADP data from PowerShell? This article demonstrates how to utilize the ADP Cmdlets for tasks like connecting to ADP data, automating operations, downloading data, and more.

The CData ADO.NET Provider for ADP is a standard ADO.NET Provider that make it easy to accomplish data cleansing, normalization, backup, and other integration tasks by enabling real-time and bidirectional access to ADP.

ADO.NET Provider

The ADO.NET Provider provides a SQL interface for ADP; this tutorial shows how to use the Provider to create, retrieve, update, and delete ADP data.

Once you have acquired the necessary connection properties, accessing ADP data in PowerShell can be enabled in three steps.

Connect to ADP by specifying the following properties:

  • OAuthClientId: The client Id of the custom OAuth application you obtained from ADP.
  • OAuthClientSecret: The custom OAuth application's client secret.
  • SSLClientCert: Set this to the certificate provided during registration.
  • SSLClientCertPassword: Set this to the password of the certificate.
  • UseUAT: The connector makes requests to the production environment by default. If using a developer account, set UseUAT = true.
  • RowScanDepth: The maximum number of rows to scan for the custom fields columns available in the table. The default value will be set to 100. Setting a high value may decrease performance.

The connector uses OAuth to authenticate with ADP. OAuth requires the authenticating user to interact with ADP using the browser. OAuth access can be configured in ADP through ADP API Central. For more information, refer ADP's API Central Quick Start Guide and the OAuth section in CData's Help documentation.

  1. Load the provider's assembly:

    
    [Reflection.Assembly]::LoadFile("C:\Program Files\CData\CData ADO.NET Provider for ADP\lib\System.Data.CData.ADP.dll")
        
  2. Connect to ADP:

     
    $conn= New-Object System.Data.CData.ADP.ADPConnection("OAuthClientId=YourClientId;OAuthClientSecret=YourClientSecret;SSLClientCert='c:\cert.pfx';SSLClientCertPassword='admin@123';InitiateOAuth=GETANDREFRESH;")
    $conn.Open()
    
  3. Instantiate the ADPDataAdapter, execute an SQL query, and output the results:

    
    $sql="SELECT AssociateOID, WorkerID from Workers"
    
    $da= New-Object System.Data.CData.ADP.ADPDataAdapter($sql, $conn)
    $dt= New-Object System.Data.DataTable
    $da.Fill($dt)
    
    $dt.Rows | foreach {
    	Write-Host $_.associateoid $_.workerid
    }
      

Update ADP Data


$cmd =  New-Object System.Data.CData.ADP.ADPCommand("UPDATE Workers SET AssociateOID='G3349PZGBADQY8H8' WHERE Id = @myId", $conn)
$cmd.Parameters.Add((New-Object System.Data.CData.ADP.ADPParameter("@myId","10456255-0015501366")))
$cmd.ExecuteNonQuery()

Insert ADP Data


$cmd =  New-Object System.Data.CData.ADP.ADPCommand("INSERT INTO Workers (AssociateOID) VALUES (@myAssociateOID)", $conn)
$cmd.Parameters.Add((New-Object System.Data.CData.ADP.ADPParameter("@myAssociateOID","G3349PZGBADQY8H8")))
$cmd.ExecuteNonQuery()

Delete ADP Data


$cmd =  New-Object System.Data.CData.ADP.ADPCommand("DELETE FROM Workers WHERE Id=@myId", $conn)
$cmd.Parameters.Add((New-Object System.Data.CData.ADP.ADPParameter("@myId","001d000000YBRseAAH")))
$cmd.ExecuteNonQuery()

Ready to get started?

Download a free trial of the ADP Data Provider to get started:

 Download Now

Learn more:

ADP Icon ADP ADO.NET Provider

Rapidly create and deploy powerful .NET applications that integrate with ADP data including Payroll, Statements, Workers, and more!