Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

Error Running OWA Audit Script

Avatar of jahhan
jahhan asked on
Microsoft IIS Web ServerPowershell
10 Comments1 Solution800 ViewsLast Modified:
I have a script that audit IIS log files for iPhone sessions.  Whenever I try to audit multiple servers I receive an error message of 'Cannot find path '\\ server2\c$\windows\system32\logfiles\W3SVC1\' because it does not exist. (Get-Content)      '
If I change the order to audit server 2 first I get the message for server1.

#Name: iPhone users syncing through OWA audit
#set the timeframe to audit in days
$Daysold = 90
$Date = (get-date).adddays(-$daysold)
$servers = 'server1' , 'server2'
foreach ($s in $servers)
    Write-host -ForegroundColor Blue "Checking server $s for files from the last $daysold day(s)"
    $logfiles += gci -path \\$s\c$\windows\system32\logfiles\W3SVC1 | where {$_.LastWriteTime -gt $date}
Foreach ($l in $logfiles)
    Write-host "Processing "$l.fullname
    Copy-item $l.fullname -Destination $pwd.path
    $listousers += gc $l.name | where {$_ -match "DeviceType="}
    Remove-Item $l.name
$user = @()
foreach ($l in $listousers | where {$_ -ne $null})
    $u = $l.split(" ")[8]
    if ($user -notcontains $u)
        $user += "$u"
    $u = $null
$body = "<!DOCTYPE html PUBLIC `"-//W3C//DTD XHTML 1.0 Strict//EN`"  `"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd`">"
$body += "<html xmlns=`"http://www.w3.org/1999/xhtml`">"
$body += "<head>"
$body += "<title>iPhone Users</title>"
$body += "</head><body>"
$body += "<table border=1>"
$body += "<colgroup>"
$body += "<col/>"
$body += "</colgroup>"
$body += "<tr><td><b>iPhone Users</b></td></tr>"
foreach ($y in $user)
    $body += "<tr><td>$y</td></tr>"
$body += "</table>"
$body += "</body></html>"

$smtpServer = "smtpserver.com"
$mailer = new-object Net.Mail.SMTPclient($smtpserver)      
$From = "user1@test.com"
$To = "user1@test.com"
$subject = "iPhone users syncing through OWA in the last $daysold day(s)"
$msg = new-object Net.Mail.MailMessage($from,$to,$subject,$body)      
$msg.IsBodyHTML = $true

Avatar of jahhan

Our community of experts have been thoroughly vetted for their expertise and industry experience.

This problem has been solved!
Unlock 1 Answer and 10 Comments.
See Answers