Exhange 2007 - Who is what
Hello,In my "organization" we have 20% of Exchange account and 80% Linux Account.To deal with spams we abviously have rules set up on the Edges. However, some spams go through and users (Linux and Exchange) receive them.Linux users forward mailsthat theyconsider as a spam to a mailbox dedicated to the SPAM. From that mailbox we gather all senders (and content) and block them on the Egdes.my question is -> From a LIST of users that forward me emails, I would need to know whetehr those users are Exchange or not. How can I do that ? through a a shell command ??Please let me know if you need further information..
May 20th, 2009 10:10am

Let me know if I misunderstood the question... You want to know that the user has mailbox on Exchange server or not. You can run Get-Mailbox cmdlet to get Exchange mailbox information but if you couldn't retrieve information then it is not in Exchange environment. Get-Mailbox "DisplayName or SMTP Address" | FT DisplayName, ServerName, Database, ExchangeVersion To get full list of information you can use below cmdlet. Get-Mailbox "DisplayName or SMTP Address" | FLAmit Tank | MVP Exchange Server | MCITP: EMA, MCSA: M | http://ExchangeShare.WordPress.com
Free Windows Admin Tool Kit Click here and download it now
May 20th, 2009 10:45am

Thanks Amit for your answer. I better provide an example.I have a list a user in a notepad document:firstname.lastname@domain.comfirstname1.lastname@domain.comfirstname2.lastname@domain.comAlias@domain.comAlias1@domain.comFrom that list I need to know who is an Exchange user. As the list can be long I was wondering whether I could get the information by running a shell command and using the notepad.txt I aldready have on my C:\ drive.The result should show me:firstname.lastname@domain.com(Exchange user)firstname1.lastname@domain.com(User not existing)firstname2.lastname@domain.com(Exchange user)Alias@domain.com(Exchange user)Alias1@domain.com(User not existing)Is that clearer?
May 20th, 2009 12:24pm

Gotcha... There could be even simpler and smaller script but I have similar kind of readymade so here it is.... Create a file with namec:\scripts\users\users.txt of each user in each line. Copy a scrip file namec:\scripts\users\UserInfo.ps1 with below scriplet content. Go to Exchange Management Shell and set a policy to run custom scripts. Set-ExecutionPolicy RemoteSigned Now, go to pathc:\scripts\users\ in EMS. Run the script with below syntax. ./UserInfo.ps1 Wait for the completion, you would see error for non Exchange users, ignore those since it will be logged into output file... All over... you have a filec:\scripts\users\UserInfo.txt with desired result... :) #========== UserInfo.ps1 content ========== $SourceFile = c:\scripts\users\users.txt $a = remove-item c:\scripts\users\UserInfo.txt -ea SilentlyContinue $error.Clear() $UserList = Get-Content $SourceFile foreach($user in $UserList) { write-host "Testing $user" $mailbox = Get-mailbox -Identity $user if($error.Count -ne 0) { $message = $user + " [Linux User]" write-output $message | out-file -filePath c:\scripts\users\UserInfo.txt -append -noClobber $error.Clear() } else { $SErverName = $Mailbox.ServerName $message = $user + " [Exchange User - $ServerName]" write-output $message | out-file -filePath c:\scripts\users\UserInfo.txt -append -noClobber } } Amit Tank | MVP Exchange Server | MCITP: EMA, MCSA: M | http://ExchangeShare.WordPress.com
Free Windows Admin Tool Kit Click here and download it now
May 20th, 2009 12:53pm

Thank you very Much Amit.just a sily question.. How tdo you create a ps1??I copied the script in a notepad document and saved it as UserInfo.ps1 on the desktop.I then drag and drop the UserInfo.ps1 file into the shell prompt and it worked. Is that the way you create ps1??Graig
May 20th, 2009 2:28pm

Yes, that's the perfect way... It is simple plain text file with just extension ps1....Amit Tank | MVP Exchange Server | MCITP: EMA, MCSA: M | http://ExchangeShare.WordPress.com
Free Windows Admin Tool Kit Click here and download it now
May 20th, 2009 2:40pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics