0

Exchange 2010 Tip Of The Day – 1 To 25

The Exchange Management Shell helps us discover the amazing capabilities of PowerShell.  One way it does this is by displaying a tip of the day so that we are introduced to concepts and topics that inevitably will come in handy one day!

Since I had not see a complete list of the Exchange 2010 ones, I thought I’d jot them down.  Exchange 2007 Tips are listed on TechNet.

Scroll down to the bottom for the PowerShell code used to retrieve this.  And yes, the first four tips really are duplicated, though since they are randomly displayed it goes un-noticed!  They remind me of a line from Red Dwarf *.

For the related articles in this series please see:

Tips 26 – 50

Tips 51 – 75

Tips 76 - 101

 

Tip of the day #1:

Did you know that the Identity parameter is a "positional parameter"? That means you can use:

Get-Mailbox "user" instead of: Get-Mailbox -Identity "user"

It's a neat usability shortcut!

Tip of the day #2:

Did you know that the Identity parameter is a "positional parameter"? That means you can use:

Get-Mailbox "user" instead of: Get-Mailbox -Identity "user"

It's a neat usability shortcut!

Tip of the day #3:

Did you know that the Identity parameter is a "positional parameter"? That means you can use:

Get-Mailbox "user" instead of: Get-Mailbox -Identity "user"

It's a neat usability shortcut!

Tip of the day #4:

Did you know that the Identity parameter is a "positional parameter"? That means you can use:

Get-Mailbox "user" instead of: Get-Mailbox -Identity "user"

It's a neat usability shortcut!

Tip of the day #5:

Tired of typing a long command every time that you want to do something? Alias it! Type:

Set-Alias GetMre Get-ManagementRoleEntry

For all the current aliases, type:

Get-Alias

Tip of the day #6:

Want to see the members of a dynamic distribution group that has a custom filter? Just use the Get-Recipient cmdlet. Type:

$DDG = Get-DynamicDistributionGroup "Contoso Marketing Managers"
Get-Recipient -RecipientPreviewFilter $DDG.RecipientFilter

Tip of the day #7:

The Exchange Management Shell is a calculator too! Try it directly at a command prompt:

1.2343+3123 or (23/435)*2

Tip of the day #8:

Command line SOS! Do you need help? Type:

Help <cmdlet-name>  or  <cmdlet-name> -?

You can choose what information to return when you view Help by using the Detailed, Full, and Examples switches:

Help Get-Mailbox -Detailed

Tip of the day #9:

Want to look at Help for a cmdlet but don't want to read through pages and pages of text in the Shell window? Just use the Online switch with the Get-Help cmdlet. The Online switch tells the Shell to open the online version of the cmdlet's Help topic in your default browser. Type:

Get-Help <cmdlet> -Online

Tip of the day #10:

The tilde character (~) should be familiar to Unix users. It represents the shortcut to your root directory. To see what it's evaluated to by default, type:

Dir ~

You can use it as a useful shortcut:

Cp SomeFile "~\My Documents"

Tip of the day #11:

CTRL+C is the equivalent of the hard-break command in the Exchange Management Shell. If a command is taking too long to run or you want to cancel an operation quickly, press CTRL+C to stop execution.

Tip of the day #12:

Pushd and Popd work the same way in the Exchange Management Shell as they do in cmd.exe. Type:

Pushd <location>

Tip of the day #13:

XML over everything! The Exchange Management Shell treats XML as a native type, so that you can do interesting things like:

$Sample = [XML](Get-Content SomeXMLFile.xml)

This command assigns $Sample to the actual XML object. To see it, type:

$Sample

To navigate, type:

$Sample.Prop1.Prop2

No need for text parsing when you want to load XML data!

Tip of the day #14:

Cmdlets that end in "Config" manage singleton configuration, either one per server or organization. For these tasks, you don't have to specify an identity because there is only one instance of the configuration. You may have to specify the Server parameter if the configuration is per server.

Tip of the day #15:

To get a list of all users on an Exchange 2010 server who aren't Unified Messaging-enabled, type:

$Mailboxes = Get-Mailbox
$Mailboxes | ForEach { If($_.UmEnabled -Eq $False){$_.Name}}

Tip of the day #16:

To get a list of all users on an Exchange 2010 server who are Unified Messaging-enabled, type:

$Mailboxes = Get-Mailbox
$Mailboxes = | ForEach { If($_.UmEnabled -Eq $True){$_.Name}}

Tip of the day #17:

To display the user's alias formatted in a table together with the user's Exchange 2010 server name and telephone extension, type:

Get-Mailbox | Format-Table ServerName,@{e={$_.SamAccountName};Label="User Alias"},@{Expression="Extensions";Label="Telephone numbers"}

Tip of the day #18:

To display the list of UM IP gateway server names disabled for outbound calling and hunt groups associated with a UM IP gateway server, type:

$Gateways = Get-UMIPGateway
$Gateways | ForEach {If($_.OutCallsAllowed -Eq $False){ "Gateway Name = " +$_.Name;ForEach ($HuntGroup In $_.Huntgroups ){"Huntgroups " + $Huntgroup}}}

Tip of the day #19:

If you want to test all IP Block List providers, you just have to pipe the Get-IpBlockListProvider cmdlet to the Test-Ip BlockListProvider cmdlet:

Get-IpBlockListProvider | Test-IpBlockListProvider -IpAddress 192.168.0.1

Tip of the day #20:

Before you remove an object by using the Remove verb, use the WhatIf parameter to verify the results are what you expect.

Tip of the day #21:

Sometimes it's useful to convert the output of a cmdlet to a string to interoperate with native cmdlets. For example, type:

Get-Mailbox | Out-String | Findstr "Administrator"

Tip of the day #22:

Get all Win32 WMI information, such as Perfmon counters and local computer configurations. For example, type:

Get-WMIObject Win32_PerfRawData_PerfOS_Memory

Tip of the day #23:

Who isn't tired of spam? You can configure real-time block list (RBL) providers with the Exchange Management Shell by running the following two commands:

Set-IPBlockListProvidersConfig -Enabled $True -ExternalMailEnabled $True

and then

Add-IPBlockListProvider -Name <Name of RBL Provider> -LookupDomain <FQDN of RBL Provider> -AnyMatch $True

Tip of the day #24:

Access the event log from the Exchange Management Shell. To retrieve the whole event log, type:

Get-EventLog Application | Format-List

To retrieve all Exchange-related events, type:

Get-EventLog Application | Where { $_.Source -Ilike "*Exchange*" }

Tip of the day #25:

One benefit of the Exchange Management Shell is that cmdlets can output objects to the console. You can then manipulate this output and organize it in interesting ways. For example, to get a quick view in tabular format, use Format-Table:

Get-Mailbox | Format-Table Name,Database,RulesQuota

 

Retrieving the Above Entries

When the Exchange Management Shell shortcut is launched it does many things.  The properties of the shortcut show the following:

C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -version 2.0 -noexit -command ". 'C:\Program Files\Microsoft\Exchange Server\V14\bin\RemoteExchange.ps1'; Connect-ExchangeServer -auto"

RemoteExchange.ps1 calls another  script --– CommonConnectFunctions.ps1.  It is the latter script that creates the Get-Tip function which is called along with others to display the banner in the Exchange Management Shell.

For more details on the Exchange Management Shell please review this post.

Rather than go through and retrieve the tips one by one, PowerShell to the rescue!  You can either use option 1 and save this to a .ps1 script or option two and just run as a oneliner.

 

Option 1 – Script File

Save the below to a .ps1 file and execute it in the Exchange Management Shell.  Uses a While loop to iterate through all of the tips.

 

# Initialise the counter with a value of 1.
$Int = 1

# PowerShell While Loop.  Iterate to a count of 105 just to show that we have returned all tips
While ($Int -le 105 )
{
Get-Tip $Int
Write-Host
# Increment the counter
$Int +=1
}

 

Option 2 – OneLiner

If you would like to just cut and paste, without reading any comments in the above go ahead and run this:

$Int = 1;While ($Int -le 105){Get-Tip $Int;  Write-Host; $Int+=1}

 

The above PowerShell code will show all of the daily tips.  To save your scroll finger from total exhaustion, the tips are split into 4 separate posts.

 

Cheers,

Rhoderick

 

* - A superlative suggestion, sir, with just two minor flaws.

One: we don't have any defensive shields. And two: we don't have any defensive shields.

Now I realise that, technically speaking, that's only one flaw; but I thought it was such a big one, it was worth mentioning twice.

Rhoderick Milne [MSFT]

Leave a Reply

Your email address will not be published. Required fields are marked *