Discover how a bimodal integration strategy can address the major data management challenges facing your organization today.
Get the Report →Automate Sage Intacct Integration Tasks from PowerShell
Are you in search of a quick and easy way to access Sage Intacct data from PowerShell? This article demonstrates how to utilize the Sage Intacct Cmdlets for tasks like connecting to Sage Intacct data, automating operations, downloading data, and more.
The CData Cmdlets for Sage Intacct 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 Sage Intacct.
PowerShell Cmdlets or ADO.NET Provider?
The Cmdlets are not only a PowerShell interface to Sage Intacct, but also an SQL interface; this tutorial shows how to use both to create, retrieve, update, and delete Sage Intacct data. We also show examples of the ADO.NET equivalent, which is possible with the CData ADO.NET Provider for Intacct. To access Sage Intacct data from other .NET applications, like LINQPad, use the CData ADO.NET Provider for Intacct.
Once you have acquired the necessary connection properties, accessing Sage Intacct data in PowerShell can be enabled in three steps.
To connect using the Login method, the following connection properties are required: User, Password, CompanyId, SenderId and SenderPassword.
User, Password, and CompanyId are the credentials for the account you wish to connect to.
SenderId and SenderPassword are the Web Services credentials assigned to you by Sage Intacct.
PowerShell
-
Install the module:
Install-Module SageIntacctCmdlets
-
Connect:
$sageintacct = Connect-SageIntacct -User "$User" -CompanyId "$CompanyId" -Password "$Password" -SenderId "$SenderId" -SenderPassword "$SenderPassword"
-
Search for and retrieve data:
$customerid = "12345" $customer = Select-SageIntacct -Connection $sageintacct -Table "Customer" -Where "CustomerId = `'$CustomerId`'" $customer
You can also use the Invoke-SageIntacct cmdlet to execute SQL commands:
$customer = Invoke-SageIntacct -Connection $sageintacct -Query 'SELECT * FROM Customer WHERE CustomerId = @CustomerId' -Params @{'@CustomerId'='12345'}
ADO.NET
-
Load the provider's assembly:
[Reflection.Assembly]::LoadFile("C:\Program Files\CData\CData ADO.NET Provider for Intacct\lib\System.Data.CData.SageIntacct.dll")
-
Connect to Sage Intacct:
$conn= New-Object System.Data.CData.SageIntacct.SageIntacctConnection("User=myusername;CompanyId=TestCompany;Password=mypassword;SenderId=Test;SenderPassword=abcde123;") $conn.Open()
-
Instantiate the SageIntacctDataAdapter, execute an SQL query, and output the results:
$sql="SELECT Name, TotalDue from Customer" $da= New-Object System.Data.CData.SageIntacct.SageIntacctDataAdapter($sql, $conn) $dt= New-Object System.Data.DataTable $da.Fill($dt) $dt.Rows | foreach { Write-Host $_.name $_.totaldue }
Update Sage Intacct Data
PowerShell
Update-SageIntacct -Connection $SageIntacct -Columns @('Name','TotalDue') -Values @('MyName', 'MyTotalDue') -Table Customer -Id "MyId"
ADO.NET
$cmd = New-Object System.Data.CData.SageIntacct.SageIntacctCommand("UPDATE Customer SET CustomerId='12345' WHERE Id = @myId", $conn)
$cmd.Parameters.Add((New-Object System.Data.CData.SageIntacct.SageIntacctParameter("@myId","10456255-0015501366")))
$cmd.ExecuteNonQuery()
Insert Sage Intacct Data
PowerShell
Add-SageIntacct -Connection $SageIntacct -Table Customer -Columns @("Name", "TotalDue") -Values @("MyName", "MyTotalDue")
ADO.NET
$cmd = New-Object System.Data.CData.SageIntacct.SageIntacctCommand("INSERT INTO Customer (CustomerId) VALUES (@myCustomerId)", $conn)
$cmd.Parameters.Add((New-Object System.Data.CData.SageIntacct.SageIntacctParameter("@myCustomerId","12345")))
$cmd.ExecuteNonQuery()
Delete Sage Intacct Data
PowerShell
Remove-SageIntacct -Connection $SageIntacct -Table "Customer" -Id "MyId"
ADO.NET
$cmd = New-Object System.Data.CData.SageIntacct.SageIntacctCommand("DELETE FROM Customer WHERE Id=@myId", $conn)
$cmd.Parameters.Add((New-Object System.Data.CData.SageIntacct.SageIntacctParameter("@myId","001d000000YBRseAAH")))
$cmd.ExecuteNonQuery()
CodeProject