[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

10/19/2009 at 09:00AM PDT, ID: 24823972
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

8.5

problem with regular expression and PSH script.

Asked by Elad-a in Powershell

Tags: powershell

Hi,
can you help change this script around a little bit? :-)

1. I'd  need to  the line: "    [Void]($_.Message -Match "(https?://)?([A-Za-z0-9\-]{2,64}\.)+[A-Za-z]{2,6}")   " to include email addresses as well as URL's (it does URL's beautifully)
2. I need  to change this line as well " @{n='Number';e={ $WhiteListEntry.PNumbers }} " as I would need in to have all the non-white listed  phone numbers in $Message displayed under  the 'Number' column.
full code blew.

make sense?
Thanks in advance for all your help.
Jason.

CSV's pasted below..

#sms_rcv.csv
Date,Time,Sender,Recipient,Status,Message,Details
9/22/2009,"1:09:21 PM","+123456789000","user@domain.com","Success","Really cool +9725568432144 stuff","Success. SMS received."
9/22/2009,"1:09:30 PM","+123456789000","user@domain.com","Success","test +298989784511 jim@janis-jop.com","Success. SMS received."
9/22/2009,"1:09:38 PM","+123456789000","user@domain.com","Success","test www.cnn.com robin hood is good","Success. SMS received."
9/22/2009,"1:09:47 PM","+123456789000","user@domain.com","Success","test +975885654321 www.art.com is there something nice to eat","Success. SMS received."

#white_list.csv
Pnumbers
972556843214,
123456789000,
975885654321,
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
#copy the file Over
gc "C:\Program Files (x86)\sms\sms_recv.log" | where {$_ -ne ""} > sms_rcv.csv
 
# Convert from UTC to this time zone (offset in hours)
 
$TimeZoneOffset = -5
 
# Load the last weeks messages from file
 
$FileName = "E:\count\sms\sms_rcv.csv"
$Messages = Import-CSV $FileName | Select-Object `
  @{n='DateTime';e={ ([DateTime]"$($_.Date) $($_.Time)").AddHours($TimeZoneOffset) }}, `
  Sender, Recipient, Status, Message, Details | `
  Where-Object { $_.DateTime -gt (Get-Date).Date.AddDays(-7) }
 
# White List Filtering
 
$WhiteList = Import-CSV "white_list.csv"
# Select all fields from $Messages and add a Known field.
# Set Confirmed if phone number followed by a space exists in white list
# digits before the phone number are ignored (such as area / country codes)
$Messages = $Messages | %{
  $Message = $_.Message
  $WhiteListEntry = $WhiteList | ?{ $Message -Match "$($_.PNumbers)\s" }
 
  $_ | Select-Object *, `
    @{n='Known';e={ If ($WhiteListEntry) { "White-listed" } else { "Not White-listed" } }}, `
    @{n='Number';e={ $WhiteListEntry.PNumbers }}
}
 
# Add the URL column
$Messages = $Messages | Select-Object *, `
  @{n='URL';e={ 
    $Matches = $Null
    [Void]($_.Message -Match "(https?://)?([A-Za-z0-9\-]{2,64}\.)+[A-Za-z]{2,6}")
    If ($Matches) { $Matches[0] }
  }}
 
# Generate the report
$Subject = "Last week there were $($Messages.Count) Items"
 
# The image at this path will be embedded into the message
 
$ImagePath = "E:\count\sms\logo1.jpg"
 
# Create the CSS Header
 
$Header = "<style>table {font-size: 10pt; font-family: calibri;}
  body {background-color:black;}
  table {align: cernter; border-width: 1px;border-style: solid; border-color: black; border-collapse: collapse;}
  th {font-size:1em; border-width: 1px;padding: 2px; border-style: solid; border-color: white; background-color: pink}
  td {font-size:0.8em; border-width: 1px;padding: 2px; border-style: solid; border-color: white; background-color: green}
</style>"
 
# Body (inserted above the HTML table)
 
$Body = "<h2><img src=cid:Logo />SMS Item Detailed Report ($Subject).</h2>"
 
# Smtp details
 
$SmtpServer = "localhost"
$From = "sender@domain"
$To = "rcpt@domain.com"
 
# Generate the full message body from the report
 
$MessageBody = $Messages | ConvertTo-Html -Head $Header -Body $Body
 
# Create the mail message
 
$MailMessage = New-Object Net.Mail.MailMessage($From, $To)
$MailMessage.Subject = $Subject
$MailMessage.IsBodyHtml = $True
 
# Create a linked resource to store the image
 
$LinkedResource = New-Object Net.Mail.LinkedResource($ImagePath, "image/jpeg")
$LinkedResource.ContentId = "Logo"; 
 
# Create an Html view and add the linked resource
 
$HtmlView = [Net.Mail.AlternateView]::CreateAlternateViewFromString($MessageBody, "text/html")
$HtmlView.LinkedResources.Add($LinkedResource)
 
# Add the view to the message
 
$MailMessage.AlternateViews.Add($HtmlView)
 
# Send the mail
 
(New-Object Net.Mail.SmtpClient($SMTPServer)).Send($MailMessage)
 
Keywords: problem with regular expression and P…
 
Loading Advertisement...
 
[+][-]10/19/09 05:16 PM, ID: 25610045

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10/19/09 11:36 PM, ID: 25611463

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10/20/09 01:17 AM, ID: 25611873

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10/20/09 01:53 AM, ID: 25612038

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10/22/09 10:47 AM, ID: 25636976

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10/22/09 10:52 AM, ID: 25637034

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10/22/09 03:13 PM, ID: 25639592

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10/23/09 05:10 AM, ID: 25643553

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10/23/09 05:16 AM, ID: 25643600

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10/23/09 10:29 AM, ID: 25646523

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10/25/09 12:14 AM, ID: 25655793

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10/25/09 10:31 AM, ID: 25657377

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Powershell
Tags: powershell
Sign Up Now!
Solution Provided By: Chris-Dent
Participating Experts: 2
Solution Grade: A
 
 
[+][-]10/25/09 10:41 AM, ID: 25657407

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10/25/09 02:07 PM, ID: 25658268

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10/25/09 02:10 PM, ID: 25658295

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091111-EE-VQP-91 - Hierarchy / EE_QW_Related_20080208