Solved

POWERSHELL

Posted on 2014-10-01
7
81 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 80

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

MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

Question has a verified solution.

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

Possible fixes for Windows 7 and Windows Server 2008 updating problem. Solutions mentioned are from Microsoft themselves. I started a case with them from our Microsoft Silver Partner option to open a case and get direct support from Microsoft. If s…
A safe way to clean winsxs folder from your windows server 2008 R2 editions
This tutorial will give a an overview on how to deploy remote agents in Backup Exec 2012 to new servers. Click on the Backup Exec button in the upper left corner. From here, are global settings for the application such as connecting to a remote Back…
This tutorial will walk an individual through the steps necessary to enable the VMware\Hyper-V licensed feature of Backup Exec 2012. In addition, how to add a VMware server and configure a backup job. The first step is to acquire the necessary licen…

733 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