Search
Windows Server

Using Windows PowerShell in an Exchange Server 2010 Environment : Managing Cmdlets

Published 1 min readBy Programming4us Editorial Team
It is a best practice to add the folder(s) that contain the custom cmdlets and scripts to the system path. This enables the administrator to run any one of the cmdlets from anywhere in the EMS console.

Cmdlets with the .ps1 extension cannot be run directly from the Cmd.exe console; they must be run within the PowerShell or Exchange Management Shell.

The cmdlets that ship with Exchange Server 2010 and EMS cannot be modified. They have been optimized and compiled for maximum performance. These native cmdlets are contained in the DLL files in the %SystemDrive%\Program Files\Microsoft\Exchange Server\bin folder.

It is a best practice to create a folder to contain the custom .ps1 files and add that folder to the system path. This facilitates the use of the .ps1 files within the EMS command line.

Developing a Common Naming Scheme

When developing custom scripts, it is important to use functional names that denote the use of the script. It is a best practice to use the same verb-noun naming that is common in PowerShell and EMS. This provides consistency in the management environment.

A script to send SMTP email from the EMS command line might be called send-email.ps1, for example.

Distributing Cmdlets

Cmdlets can be distributed in a number of ways, similar to VBScripts or batch files.

The Microsoft distributed file system (DFS) offers another way to distribute cmdlets. By creating replicas in remote sites, the organization’s cmdlet library can be fault tolerant and available locally to all administrators.

Another option for distributing cmdlets is via SharePoint. SharePoint’s document management features enable administrators to check in and check out cmdlets as .ps1 files. This makes managing .ps1 files simple and provides full-text search capabilities. It also provides security so that only the appropriate administrators have access to certain cmdlets.

Note

Because .ps1 files are executable code, they cannot be sent using Outlook due to the Outlook security restrictions. Cmdlets can be zipped into compressed folders and emailed as attachments, or their contents can be pasted into the body of a message.