Home > Microsoft Exchange Tips > Exchange Server Administration Tips > How to run Exchange Management Shell cmdlets in Exchange Server 2007
Exchange Tips:
EMAIL THIS
 TIPS & NEWSLETTERS TOPICS 

EXCHANGE SERVER ADMINISTRATION TIPS

How to run Exchange Management Shell cmdlets in Exchange Server 2007


Brien Posey
12.10.2008
Rating: -3.50- (out of 5)


Exchange Server tips, tutorials and expert advice
Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us    Add to Google


Exchange Server 2007 has several cmdlets built into Exchange Management Shell (EMS). You can also create custom cmdlets to automate tedious or repetitive tasks in Exchange 2007. But one common problem experienced after creating your own cmdlets is getting them to run. Here's what you need to know about cmdlet execution, including PowerShell policy settings, and how to create your own custom cmdlet library.

The Exchange Management Shell is built on Windows PowerShell, a rich scripting environment. A problem with PowerShell is that Microsoft focused heavily on security to prevent that environment from becoming the ultimate tool for creating viruses, Trojans and other types of malicious scripts. Therefore, Microsoft limited what can be done through PowerShell.

EMS has several built-in cmdlets, but you're restricted in what you can do with them. You're allowed to include calls to all built-in cmdlets as well as those that you build. For example, Get-Mailbox is a built-in cmdlet; it's also acceptable to include this command within a self-designed cmdlet.

You can't, however, modify any built-in cmdlets. The cmdlets you make exist as .PS1 files, while Microsoft embedded built-in cmdlets in a .DLL file to prevent tampering. In addition, you can't make a direct call to a custom cmdlet.

For example, if you were to create a cmdlet named TEST.PS1, you wouldn't be able to run it by opening the Exchange Management Shell and entering TEST.PS1. Instead, you must enter the full path to the cmdlet, even if the .PS1 file resides in the current directory. Therefore, entering TEST.PS1 would be invalid; entering something like C:\TEMP\TEST.PS1 would be valid.

Microsoft also included execution policy settings in PowerShell to prevent scripts from being executed accidentally. There are three built-in execution policies.


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us    Add to Google



RELATED CONTENT
Microsoft Exchange Server Scripts and Programming
Removing old disclaimers from Exchange Server 2003
Automate complex Exchange 2007 Management Shell tasks via scripting
Exchange event sink scripting error when configuring email disclaimer
EMS add-on tool generates graphical Exchange Server 2007 reports
A primer on the Exchange Server 2007 Exchange Management Shell
How to generate HTML reports with the Exchange Management Shell (EMS)
Use the Exchange Management Shell Set command to block senders
How to test Exchange Management Shell commands
Grant or deny permissions to access a user's Exchange 2007 mailbox
Control query results with Exchange Management Shell's Format command

Microsoft Exchange Server 2007
Displaying Exchange 2007 public folders in SharePoint
Don'ts for optimal Exchange 2007 mailbox server efficiency
Is your Exchange 2007 hub transport server healthy?
Top 5 Exchange ActiveSync tips
Two useful tools for documenting an Exchange Server installation
Controlling spam in Exchange 2007 at the edge transport server level
Restore Exchange storage groups with DPM 2007
How a hosted Exchange service can help you
Email issues after configuring hosted Exchange server on laptop
Migrating to Exchange 2007 with correct permissions
Microsoft Exchange Server 2007 Research

Exchange Server Administration Tips
Remove Exchange 2003 objects from AD to install Exchange 2010
Don'ts for optimal Exchange 2007 mailbox server efficiency
Is your Exchange 2007 hub transport server healthy?
Avoid Outlook 2007 performance issues during repairs
Developing an Exchange 2007 server role DR plan
How DSAccess service improves Exchange Server 2007 reliability
An introduction to the Exchange Remote Connectivity Analyzer tool
Monitor Exchange 2007 with disk- and RPC-related counters
DPM 2007 replica inconsistencies in Exchange databases
Track Exchange 2007 mailbox server health using database counters

RELATED GLOSSARY TERMS
Terms from Whatis.com − the technology online dictionary
application program interface  (SearchExchange.com)
event sink  (SearchExchange.com)
synchronous groupware  (SearchExchange.com)

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary


>AllSigned -- This policy means that PowerShell scripts will not execute unless a trusted certificate authority has digitally signed the script.

RemoteSigned -- When this policy level is in effect, any scripts that have been downloaded from the Internet must be signed, but local scripts don't have to be signed.

Unrestricted -- As the name implies, when this policy level is in effect, Windows allows any PowerShell script to execute, regardless of whether or not it's been digitally signed.

Having a choice of execution policies raises the question of which policy is in effect, and how you can change policies if you want to. You can check the current execution policy by opening either PowerShell or Exchange Management Shell and entering:

Get-ExecutionPolicy

A native PowerShell deployment will use the AllSigned execution policy by default. When you install Exchange 2007 onto a server, the execution policy is set to RemoteSigned. If the execution policy is set to RemoteSigned, you should be able to execute any cmdlets you create, as long as they reside on the server.

Creating a custom cmdlet library

As you work with PowerShell, you'll eventually grow more comfortable with it. Over time, you'll probably start accumulating a collection of custom cmdlets. I recommend setting up a cmdlet library, which is simply a collection of cmdlets.

I don't think Microsoft has any official guidelines for setting up a cmdlet library. If you only have a single Exchange 2007 server, creating the library is as easy as creating a folder on the server and copying the cmdlets to it.

If you have multiple Exchange 2007 servers, then you'll probably want the cmdlets to reside on each server. One way to accomplish this is to create a distributed file system (DFS) tree in which the folder containing cmdlets is replicated to each Exchange 2007 server.

About the author: Brien M. Posey, MCSE, is a five-time recipient of Microsoft's Most Valuable Professional award for his work with Exchange Server, Windows Server, Internet Information Services (IIS), and File Systems and Storage. Brien has served as CIO for a nationwide chain of hospitals and was once responsible for the Department of Information Management at Fort Knox. As a freelance technical writer, Brien has written for Microsoft, TechTarget, CNET, ZDNet, MSD2D, Relevant Technologies and other technology companies. You can visit Brien's personal website at www.brienposey.com.

Do you have comments on this tip? Let us know.

Please let others know how useful this tip was via the rating scale below. Do you know a helpful Exchange Server, Microsoft Outlook or SharePoint tip, timesaver or workaround? Email the editors to talk about writing for SearchExchange.com.

Rate this Tip
To rate tips, you must be a member of SearchExchange.com.
Register now to start rating these tips. Log in if you are already a member.




DISCLAIMER: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.



Email Server Solutions: Exchange 2007, Exchange 2003, Exchange 2000, SharePoint
HomeNewsTopicsITKnowledge ExchangeTipsAsk the ExpertsMultimediaWhite PapersIT Downloads
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations' technology projects - with its network of technology-specific websites, events and online magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Site Map




All Rights Reserved, Copyright 2004 - 2009, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts