[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Exchange 2010, PowerShell

Posted on 2014-01-30
4
Medium Priority
?
500 Views
Last Modified: 2014-01-31
I am trying to use this script here:

http://theboywonder.co.uk/2012/03/15/speeding-up-get-winevent-in-powershell-by-using-filterhashtable/

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.

Thanks,

Robert
0
Comment
Question by:castellansolutions
[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
  • 2
  • 2
4 Comments
 
LVL 41

Expert Comment

by:footech
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

0
 
LVL 6

Author Comment

by:castellansolutions
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 ?
0
 
LVL 41

Accepted Solution

by:
footech earned 2000 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

0
 
LVL 6

Author Comment

by:castellansolutions
ID: 39825647
Works like a charm!
0

Featured Post

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

Here in this article, you will get a step by step guidance on how to restore an Exchange database to a recovery database. Get a brief on Recovery Database and how it can be used to restore Exchange database in this section!
If something goes wrong with Exchange, your IT resources are in trouble.All Exchange server migration processes are not designed to be identical and though migrating email from on-premises Exchange mailbox to Cloud’s Office 365 is relatively simple…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

656 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