Exchange 2010, PowerShell

Posted on 2014-01-30
Last Modified: 2014-01-31
I am trying to use this script here:

To do the following:

1) Scan all the exchange servers in the Organization and collect the events.

The commands work individually however I cannot figure out how to make the script connect to each of the Servers in the Exchange Organization. I tried using the command:

[PS] C:\>Get-WinEvent -FilterHashTable @{LogName='Application'; Level=1,2,3; StartTime="1/1/2014"} -ErrorAction Silently
Continue -Computer $Servers | Select-Object TimeCreated,LogName,ProviderName,Id,LevelDisplayName,Message
Get-WinEvent : Cannot convert 'System.Object[]' to the type 'System.String' required by parameter 'ComputerName'. Speci
fied method is not supported.
At line:1 char:130
+ Get-WinEvent -FilterHashTable @{LogName='Application'; Level=1,2,3; StartTime="1/1/2014"} -ErrorAction SilentlyContin
ue -Computer <<<<  $Servers | Select-Object TimeCreated,LogName,ProviderName,Id,LevelDisplayName,Message
    + CategoryInfo          : InvalidArgument: (:) [Get-WinEvent], ParameterBindingException
    + FullyQualifiedErrorId : CannotConvertArgument,Microsoft.PowerShell.Commands.GetWinEventCommand

AS you can see it did not work. I really am not a scripter so I am hoping you can help out here. I created my own server variable using the :

[PS] C:\>$Servers = get-content -Path c:\servers.txt

That worked however I still cannot use the command to get all the computers and then gather all the event logs.


Question by:castellansolutions
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
  • 2
  • 2
LVL 40

Expert Comment

ID: 39823170
The simplest method is to process each server individually.
Try the following:
get-content -Path c:\servers.txt | ForEach `
    Get-WinEvent -FilterHashTable @{LogName='Application'; Level=1,2,3; StartTime="1/1/2014"} -ErrorAction SilentlyContinue -Computer $_ |
     Select-Object TimeCreated,LogName,ProviderName,Id,LevelDisplayName,Message

Open in new window


Author Comment

ID: 39824533
This is great!! It worked however there is one last thing that I need to figure out, when I use the command it doesn't provide the server name where the events were generated from.

So in my lab I have 16 Exchange Servers.... How do I add the name ?
LVL 40

Accepted Solution

footech earned 500 total points
ID: 39824578
We can add that as a calculated property with Select-Object.
get-content -Path c:\servers.txt | ForEach `
    $server = $_
    Get-WinEvent -FilterHashTable @{LogName='Application'; Level=1,2,3; StartTime="1/1/2014"} -ErrorAction SilentlyContinue -Computer $_ |
     Select-Object @{n="Server";e={$server}},TimeCreated,LogName,ProviderName,Id,LevelDisplayName,Message

Open in new window


Author Comment

ID: 39825647
Works like a charm!

Featured Post

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

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

This script can help you clean up your user profile database by comparing profiles to Active Directory users in a particular OU, and removing the profiles that don't match.
Previously, on our Nano Server Deployment series, we've created a new nano server image and deployed it on a physical server in part 2. Now we will go through configuration.
In this video we show how to create an Address List in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.: First we need to log into the Exchange Admin Center. Navigate to the Organization >> Ad…
The video tutorial explains the basics of the Exchange server Database Availability groups. The components of this video include: 1. Automatic Failover 2. Failover Clustering 3. Active Manager

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