Solved

POWERSHELL

Posted on 2014-10-01
7
83 Views
Last Modified: 2015-02-04
Hello
3 files are uploaded in /tmp All days
name of files :
YYYYMMDD_TIME_file1.xml
YYYYMMDD_TIME_file2.xml
YYYYMMDD_TIME_file3.xml

i d like to monitor if the 3 files are well in /tmp All days.  and if no , email alert

How Can i do with powershell please?

Regards
Laurent
0
Comment
Question by:LaurentLyon
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 29

Expert Comment

by:becraig
ID: 40355673
i d like to monitor if the 3 files are well in /tmp All days.  and if no , email alert


I am not sure what you mean, do you mean you want to know if 3 files matching the current date exist in the folder ?

e.g today is
20141001  so you want to check whether
20141001  _TIME_file1.xml
20141001  _TIME_file2.xml
20141001  _TIME_file3.xml
exists, and send an email if they do not ?
0
 

Author Comment

by:LaurentLyon
ID: 40355687
Hello
Yes , and All days :)
i just want to know if they are well here , and if one file is not here then email alert
thanks
0
 
LVL 81

Expert Comment

by:David Johnson, CD, MVP
ID: 40355910
$basepath = "c:\test\"
$filter = get-date -Format yyyy-mm-dd
$filter2 = "*.xml"
$filter = $filter + $filter2
$items = Get-ChildItem -Path $basepath -Filter $filter2
$items.count
if ($items.count -lt 4) {
Write-Output ("send email")
}

Open in new window

0
 

Author Comment

by:LaurentLyon
ID: 40356685
Hello , thanks David ,

I d prefer that the script email an alert with the files missing ?


Regards
Laurent
0
 
LVL 14

Accepted Solution

by:
Justin Yeung earned 500 total points
ID: 40362613
$path = "c:\test"
$date = get-date -Format yyyy-mm-dd
[array]$files = @("$date*file1.xml","$date*file2.xml","$date*file3.xml")
foreach ($file in $files)
{
if (!(get-childitem -path $path -name $file))
{
send-mailmessage -from someone@some.com -to someone@some.como -subject "no file found" -body "file with name $file is not found in here" -smtpserver yoursmtp
}

}

Open in new window

0

Featured Post

Free NetCrunch network monitor licenses!

Only on Experts-Exchange: Sign-up for a free-trial and we'll send you your permanent license!

Here is what you get: 30 Nodes | Unlimited Sensors | No Time Restrictions | Absolutely FREE!

Act now. This offer ends July 14, 2017.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A recent project that involved parsing Tableau Desktop and Server log files to extract reusable user queries for use in other systems. I chose to use PowerShell to gather the data, and SharePoint to present it...
This article provides a convenient collection of links to Microsoft provided Security Patches for operating systems that have reached their End of Life support cycle. Included operating systems covered by this article are Windows XP,  Windows Server…
To efficiently enable the rotation of USB drives for backups, storage pools need to be created. This way no matter which USB drive is installed, the backups will successfully write without any administrative intervention. Multiple USB devices need t…
This tutorial will walk an individual through setting the global and backup job media overwrite and protection periods in Backup Exec 2012. Log onto the Backup Exec Central Administration Server. Examine the services. If all or most of them are stop…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question