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.

Automate ADP Integration Tasks from PowerShell



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 Cmdlets for ADP are standard PowerShell cmdlets that make it easy to accomplish data cleansing, normalization, backup, and other integration tasks by enabling real-time and bidirectional access to ADP.

PowerShell Cmdlets or ADO.NET Provider?

The Cmdlets are not only a PowerShell interface to ADP, but also an SQL interface; this tutorial shows how to use both to create, retrieve, update, and delete ADP data. We also show examples of the ADO.NET equivalent, which is possible with the CData ADO.NET Provider for ADP. To access ADP data from other .NET applications, like LINQPad, use the CData ADO.NET Provider for ADP.

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:

  • 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. For more information, refer to the OAuth section in the Help documentation.

PowerShell

  1. Install the module:

    Install-Module ADPCmdlets
  2. Connect:

    $adp = Connect-ADP -OAuthClientId "$OAuthClientId" -OAuthClientSecret "$OAuthClientSecret" -SSLClientCert "$SSLClientCert" -SSLClientCertPassword "$SSLClientCertPassword"
  3. Search for and retrieve data:

    $associateoid = "G3349PZGBADQY8H8" $workers = Select-ADP -Connection $adp -Table "Workers" -Where "AssociateOID = `'$AssociateOID`'" $workers

    You can also use the Invoke-ADP cmdlet to execute SQL commands:

    $workers = Invoke-ADP -Connection $adp -Query 'SELECT * FROM Workers WHERE AssociateOID = @AssociateOID' -Params @{'@AssociateOID'='G3349PZGBADQY8H8'}

ADO.NET

  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

PowerShell

Update-ADP -Connection $ADP -Columns @('AssociateOID','WorkerID') -Values @('MyAssociateOID', 'MyWorkerID') -Table Workers -Id "MyId"

ADO.NET

$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

PowerShell

Add-ADP -Connection $ADP -Table Workers -Columns @("AssociateOID", "WorkerID") -Values @("MyAssociateOID", "MyWorkerID")

ADO.NET

$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

PowerShell

Remove-ADP -Connection $ADP -Table "Workers" -Id "MyId"

ADO.NET

$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()