I have to schedule a jams job for sending a report to a client. But my job failed and I get an error in the log file
The term 'sqlcmd' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
This is my PowerShell script:
param (
[string]$DatabaseServer = "COREP02P.centiv.com",
[string]$SFTPPath = "/home/cdibrm02/",
[string]$SFTPServer = "test-externalftp.prudential.com",
[string]$SFTPCredential = "PrudentiaReport-SFTP-Test",
[string]$JamsServerName = "jams01d.brandmuscle.local"
)
Import-Module JAMS
$localDataDirectory = "C:\temp\$(New-Guid)"
New-Item $localDataDirectory -itemType directory
$Prudential_EmailCampaignReport = "$localDataDirectory\Prudential_EmailCampaignReport.txt"
$Prudential_EmailCampaignReportFile = "$localDataDirectory\Prudential_EmailCampaignReportFile.txt"
# run reports
sqlcmd -S $Databaseserver -E -d "CentivPos" -Q "Exec [dbo].[Prudential_EmailCampaignReport]" -o $Prudential_EmailCampaignReport -W -s "," -h -1
(get-content $Prudential_EmailCampaignReport | select -Skip 1) | select-string -pattern "Warning" -notmatch | select-string -pattern "affected" -notmatch | select-string -pattern "--------" -notmatch | set-content $Prudential_EmailCampaignReport
$Data = Get-Content $Prudential_EmailCampaignReport -Raw
$Cleanup = $Data.Replace("`n`r`n","").Replace("`n`n","").Replace("`r","")
$Cleanup = $Cleanup | Set-Content $Prudential_EmailCampaignReport -Force
#get filename
$filename = (Get-Content $Prudential_EmailCampaignReport -First 1).Substring(44, 45)