├── LICENSE ├── PowerShell ├── 1-DMTLoad.ps1 ├── 2-BAQExtractAndLoad.ps1 ├── 3-DBExtractAndLoad.ps1 └── 4-ExtractAndLoadAndEmail.ps1 └── README.md /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 StephenEdginton 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /PowerShell/1-DMTLoad.ps1: -------------------------------------------------------------------------------- 1 | #DMT Automation Example 1 2 | 3 | $DMTPath = "C:\Epicor\ERP10\LocalClients\ERP10\DMT.exe" 4 | $User = "epicor" 5 | $Pass = "epicor" 6 | $Source = "C:\Temp\Product.csv" 7 | 8 | 9 | #Load Data 10 | Start-Process -Wait -FilePath $DMTPath -ArgumentList "-User $User -Pass $Pass -Delete -Import Part -Source $Source " 11 | -------------------------------------------------------------------------------- /PowerShell/2-BAQExtractAndLoad.ps1: -------------------------------------------------------------------------------- 1 | #DMT Automation Example 2 2 | 3 | #Extract Data From From BAQ -> CSV File -> Load in with DMT 4 | 5 | $DMTPath = "C:\Epicor\ERP10\LocalClients\ERP10\DMT.exe" 6 | $User = "epicor" 7 | $Pass = "epicor" 8 | 9 | $Source = "C:\Temp\CustomerList.csv" 10 | $completeLog = $source + ".CompleteLog.txt" 11 | 12 | Write-Output "Extracting Data via BAQ $(get-date)" 13 | 14 | Start-Process -Wait -FilePath $DMTPath -ArgumentList "-User $User -Pass $Pass -Export -BAQ CustomerDetails -Target $Source -NoUI -ConfigValue=ERP10" 15 | Write-Output "Loading Data $(get-date) " $Source 16 | 17 | #Load Data 18 | Start-Process -Wait -FilePath $DMTPath -ArgumentList "-User $User -Pass $Pass -Add -Update -Import Customer -Source $Source " 19 | 20 | #Check Results 21 | select-string -Path $completeLog -Pattern "Records:\D*(\d+\/\d+)" -AllMatches | % { $_.Matches.Groups[0].Value } 22 | select-string -Path $completeLog -Pattern "Errors:\D*(\d+)" -AllMatches | % { $_.Matches.Groups[0].Value } -------------------------------------------------------------------------------- /PowerShell/3-DBExtractAndLoad.ps1: -------------------------------------------------------------------------------- 1 | #DMT Automation Example 3 2 | 3 | #Extract Data From DB -> CSV File -> Load in with DMT 4 | 5 | Import-module "sqlps" -DisableNameChecking 6 | $DMTPath = "C:\Epicor\ERP10\LocalClients\ERP10\DMT.exe" 7 | $User = "epicor" 8 | $Pass = "epicor" 9 | 10 | $Source = "C:\Temp\Product.csv" 11 | $completeLog = $source + ".CompleteLog.txt" 12 | 13 | Write-Output "Extracting Data" 14 | #Extract Data 15 | Invoke-SqlCmd -Query "SELECT TOP 50 16 | 'EPIC06' As Company, 17 | ProductNumber As PartNum, 18 | Name As PartDescription, 19 | (Case when [MakeFlag] = 0 then 'P' else 'M' END) as TypeCode 20 | FROM [AdventureWorks2012].[Production].[Product]" | Export-Csv -NoType $Source 21 | 22 | 23 | Write-Output "Extracted : " Import-Csv $Source | Measure-Object | % {$_.Count} 24 | 25 | Write-Output "Loading Data " $Source 26 | 27 | #Load Data 28 | Start-Process -Wait -FilePath $DMTPath -ArgumentList "-User $User -Pass $Pass -Add -Update -Import Part -Source $Source " 29 | 30 | #Check Results 31 | select-string -Path $completeLog -Pattern "Records:\D*(\d+\/\d+)" -AllMatches | % { $_.Matches.Groups[0].Value } 32 | select-string -Path $completeLog -Pattern "Errors:\D*(\d+)" -AllMatches | % { $_.Matches.Groups[0].Value } 33 | -------------------------------------------------------------------------------- /PowerShell/4-ExtractAndLoadAndEmail.ps1: -------------------------------------------------------------------------------- 1 | #DMT Automation Example 4 2 | 3 | #Extract Data From DB -> CSV File -> Load in with DMT -> Send Email on Completion 4 | 5 | Import-module "sqlps" -DisableNameChecking 6 | $DMTPath = "C:\Epicor\ERP10\LocalClients\ERP10\DMT.exe" 7 | $User = "epicor" 8 | $Pass = "epicor" 9 | 10 | $Source = "C:\Temp\Product.csv" 11 | $completeLog = $source + ".CompleteLog.txt" 12 | 13 | Write-Output "Extracting Data" 14 | #Extract Data 15 | Invoke-SqlCmd -Query "SELECT TOP 50 16 | 'EPIC06' As Company, 17 | ProductNumber As PartNum, 18 | Name As PartDescription, 19 | (Case when [MakeFlag] = 0 then 'P' else 'M' END) as TypeCode 20 | FROM [AdventureWorks2012].[Production].[Product]" | Export-Csv -NoType $Source 21 | 22 | 23 | Write-Output "Extracted : " Import-Csv $Source | Measure-Object | % {$_.Count} 24 | 25 | Write-Output "Loading Data " $Source 26 | 27 | #Load Data 28 | Start-Process -Wait -FilePath $DMTPath -ArgumentList "-User $User -Pass $Pass -Add -Update -Import Part -Source $Source " 29 | 30 | #Check Results 31 | select-string -Path $completeLog -Pattern "Records:\D*(\d+\/\d+)" -AllMatches | % { $_.Matches.Groups[0].Value } 32 | select-string -Path $completeLog -Pattern "Errors:\D*(\d+)" -AllMatches | % { $_.Matches.Groups[0].Value } 33 | 34 | Send-MailMessage -From DMT@YourCompany.com -Subject "Job Done" -To administrator@yourcompany.com -Attachments $completeLog -Body "DMT Completed" -SmtpServer localhost 35 | 36 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # EpicorDMTScripts 2 | Epicor DMT Scripts for Automation 3 | 4 | This provides a number of examples of using PowerShell to automate the Data Managment Tool for Epicor ERP. 5 | 6 | 7 | --------------------------------------------------------------------------------