Skip to main content

Posts

Showing posts with the label Exchange 2010

What Snap-ins are required to access the Exchange Cmdlets?

PowerShell utilized both Snapins and Modules to expand its functionality.  For those of you needing to do some exchange scripting, you will need access to the Exchange Snapins.  These snap ins are installed on your Exchange server.  If you would like to work off of a client, then use the Exchange installation media to install the Exchange Management Tools to your client.   These snapins are for Exchange 2010. Microsoft.Exchange.Management.PowerShell.E2010 Microsoft.Exchange.Management.PowerShell.Setup Microsoft.Exchange.Management.PowerShell.Support   To register these snapins quickly in the ISE, type this command in the Command window: Get-PSSnapin –Registered | ForEach-Object {Add-PSSnapin –Name $_.Name}

Filter an Object to Help Send Data to a Cmdlet via the Pipeline.

I took a question posted on this blog about a unique Exchange issue that an administrator was having.  They needed to take a CSV file containing names and pipe it to cmdlets for Exchange Server to take actions on.  The problem is that one of the parameters of a cmdlet would not accept the input.  The code below is designed to take any object and get a list of its properties.  (In the Exchange Administrators case, the object was created using the Import-CSV cmdlet.) This cmdlet also took a look at the cmdlet that you intend to pipe the final data to.  It will extract the parameters of this cmdlet.  It then compares the each property of the object with the parameters of the cmdlet.  If there is a match, the property will be passed to the pipeline.  If not, it will be dropped.  In the help file, two examples are given.  One that has a cmdlet in which all parameters accept values via the pipeline and one that does not.  To read more a...

Use PowerShell to Discover Mailboxes that have Recipient Restrictions.

Exchange Server has a neat little property on each mailbox that allows you to restrict from whom email can be received from.  An example of this would be when you have a contractor working in your organization.  Your provide them with an account and email so they can correspond with you or the team that they are working with.  If you want to prevent them from receiving emails from others on this account, you can set up a restriction. In the Exchange Manager Console, expand Microsoft Exchange \ Microsoft Exchange (On-Premises) \ Recipient Configuration \ Mailbox . Open the properties of the user in question. Click the Mail Flow Settings . Double click Message Delivery Restrictions . Select Only Senders in the following List Click Add . Select the users or groups that you want this user to be able to receive email from. Click OK three times. Now that is set up, back to the question.  How do you find all off the users with restrictions on who or whom they can...

How to set a Server Side Autoreply with PowerShell

The question from class was how to set a mailbox to autoreply to the sender.  In this case, if the sender is requesting support, this auto response will let them know that their email has been received.  It turns out this is a simple one liner in PowerShell. The below command is one continuous line.  This needs to be execute in the Exchange Management Console on the Exchange server. Set-MailboxAutoReplyConfiguration –Identity ITHelpdesk –InternalMessage “ Thank you. Your message has been received. A member of the help desk will contact you shortly. ” –AutoReplyState Enabled Below is how it appears in Outlook for the user who sent the request. If you expect email from outside your organization, you can also set an external rule. Set-MailboxAutoReplyConfiguration –Identity ITHelpdesk –InternalMessage “ Thank you. Your message has been received. A member of the help desk will contact you shortly. ” –ExternalMessage “ Thank you. Your message has been received. A ...

Determine if the Exchange Database is Mounted with PowerShell

While delivering a class at the Federal Reserve, I had the opportunity to help out with optimizing a script for use on exchange.  The script needed to check to see if the database is mounted.  The student was able to see it mounted, but could not extract the exact integer value from the data.  Below is how we did it. Get-Counter -Counter ' \MSExchange Active Manager(*)\Database Mounted ' | ForEach-Object { $_ .CounterSamples} | Select-Object -Property InstanceName, CookedValue   The CookedValue is what they were ultimately looking for. 0 means dismounted and 1 means mounted.

Extract mailboxes that are forwarding email outside of your domain with PowerShell

  While instructing a PowerShell class at the Federal Reserve Bank in Philadelphia, I took an opportunity to take a real PowerShell need and incorporate it into class.  The need was to discover any user accounts that had rules in Outlook that forward emails outside of the organization.  Below is the resulting script.     # This code is intended to run on the Exchange server in the # Exchange Management Shell.   It is also intended to be a # module or Dot sourced into the session. # Enable the line of code below to Import the Exchange cmdlets. # Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010   <# .SYNOPSIS Retrieves mailboxes that have forwarding rules outside of your email system. .DESCRIPTION Retrieves mailboxes that have forwarding rules outside of your email system and presents you with the mailbox owner and the forwarded address .PARAMETER EmailDomain The name of your email domain.   Any forward rules that do not ...