Quantcast
Channel: SQLServerCentral » Programming » Powershell » Latest topics
Viewing all articles
Browse latest Browse all 467

Syntax error help please

$
0
0
Hello EveryoneI am running the below script which is meant to check the creation date of certain files and send an email if the file is missing or if the creation date is not current date. When I run it in an agent job I get this error and can't figure out the correct syntax. Any help would be appreciated.ERROR: 'A parameter cannot be found that matches parameter name 'eq'. '. Process Exit Code -1Code[code="plain"]Set-ExecutionPolicy RemoteSigned -ErrorAction SilentlyContinue$today = (get-date).Date$file1 = "CRAADDET" $file2 = "CRACRDTL"$file3 = "CRACRDDB" $file4 = "CRACON" $file5 = "CRACONDB"$file6 = "CRAAAD"$file7 = "CRAAPPDB"$files8 = "CRAAAD2"$files9 = "SCORECARDAPP"if((Test-Path -Path "\jfocus01\WFMASTERS\Created\$file1*.tab" -eq (get-date)) -eq $true) {Write-host $file1-ForegroundColor Green " File Exists"Send-MailMessage -From "NJFOCUS01@marlinleasing.com" -To "dbrown@marlinleasing.com" -SmtpServer "njmail03.marlincorp.com" -Body "Success" -Subject "$file1 - Arrived Successfully" } else {Write-Host $file1 -ForegroundColor Yellow "Does Not Exist"} if((Test-Path -Path "\jfocus01\WFMASTERS\Created\$file2*.tab" -eq (get-date)) -eq $true) {Write-host $file2 -ForegroundColor Green "File Exists"Send-MailMessage -From "NJFOCUS01@marlinleasing.com" -To "dbrown@marlinleasing.com" -SmtpServer "njmail03.marlincorp.com" -Body "Success" -Subject "$file2 - Arrived Successfully" } else {Write-host $file2 -ForegroundColor Yellow "Does Not Exist"} if((Test-Path -Path "\jfocus01\WFMASTERS\Created\$file3*.tab" -eq (get-date)) -eq $true) {Write-host $file3 -ForegroundColor Green "File Exists"Send-MailMessage -From "NJFOCUS01@marlinleasing.com" -To "dbrown@marlinleasing.com" -SmtpServer "njmail03.marlincorp.com" -Body "Success" -Subject "$file3 - Arrived Successfully" } else {Write-host $file3 -ForegroundColor Yellow "Does Not Exist"} if((Test-Path -Path "\jfocus01\WFMASTERS\Created\$file4*.tab" -eq (get-date)) -eq $true) {Write-host $file4 -ForegroundColor Green "File Exists"Send-MailMessage -From "NJFOCUS01@marlinleasing.com" -To "dbrown@marlinleasing.com" -SmtpServer "njmail03.marlincorp.com" -Body "Success" -Subject "$file4 - Arrived Successfully" } else {Write-host $file4 -ForegroundColor Yellow "Does Not Exist"} if((Test-Path -Path "\jfocus01\WFMASTERS\Created\$file5*.tab" -eq (get-date)) -eq $true) {Write-host $file5 -ForegroundColor Green "File Exists"Send-MailMessage -From "NJFOCUS01@marlinleasing.com" -To "dbrown@marlinleasing.com" -SmtpServer "njmail03.marlincorp.com" -Body "Success" -Subject "$file5 - Arrived Successfully" } else {Write-host $file5 -ForegroundColor Yellow "Does Not Exist"}if((Test-Path -Path "\jfocus01\WFMASTERS\Created\$file6*.tab" -eq (get-date)) -eq $true) {Write-host $file1-ForegroundColor Green " File Exists"Send-MailMessage -From "NJFOCUS01@marlinleasing.com" -To "dbrown@marlinleasing.com" -SmtpServer "njmail03.marlincorp.com" -Body "Success" -Subject "$file1 - Arrived Successfully" } else {Write-Host $file1 -ForegroundColor Yellow "Does Not Exist"}if((Test-Path -Path "\jfocus01\WFMASTERS\Created\$file7*.tab" -eq (get-date)) -eq $true) {Write-host $file1-ForegroundColor Green " File Exists"Send-MailMessage -From "NJFOCUS01@marlinleasing.com" -To "dbrown@marlinleasing.com" -SmtpServer "njmail03.marlincorp.com" -Body "Success" -Subject "$file1 - Arrived Successfully" } else {Write-Host $file1 -ForegroundColor Yellow "Does Not Exist"}if((Test-Path -Path "\jfocus01\WFMASTERS\Created\$file8*.tab" -eq (get-date)) -eq $true) {Write-host $file1-ForegroundColor Green " File Exists"Send-MailMessage -From "NJFOCUS01@marlinleasing.com" -To "dbrown@marlinleasing.com" -SmtpServer "njmail03.marlincorp.com" -Body "Success" -Subject "$file1 - Arrived Successfully" } else {Write-Host $file1 -ForegroundColor Yellow "Does Not Exist"}if((Test-Path -Path "\jfocus01\WFMASTERS\Created\$file9*.tab" -eq (get-date)) -eq $true) {Write-host $file1-ForegroundColor Green " File Exists"Send-MailMessage -From "NJFOCUS01@marlinleasing.com" -To "dbrown@marlinleasing.com" -SmtpServer "njmail03.marlincorp.com" -Body "Success" -Subject "$file1 - Arrived Successfully" } else {Write-Host $file1 -ForegroundColor Yellow "Does Not Exist"} [/code]

Viewing all articles
Browse latest Browse all 467

Trending Articles