Exchange 2010 adds a lot of new commands to the Exchange Management Shell (EMS). In addition to the new commands, some commands were removed and some cmdlet parameters have changed. To find all the changes between the two versions of Exchange I put together a script that produces a collection of custom objects. By querying these objects you can find if a command or its parameters are new or removed. The changes are recorded in an XML file (compare.xml) which you can use to filter a specific command.
To compare the changes I ran a script, on each version of Exchange, that exports all the Exchange commands (Name and a list of parameters) to an XML file using the Export-CliXml cmdlet.
#Exchange 2007 SP2 (Thanks Mike!)
Add-PSSnapin Microsoft.Exchange* -ErrorAction SilentlyContinue
Get-Command -Module Microsoft.Exchange* | Select-Object Name,@{n='Parameters';e={$_.Parameters.Keys}} | Export-CliXml .\2007.xml
#Exchange 2010 Update Rollup 1
Get-Command -Module $importResults | Select-Object Name,@{n='Parameters';e={$_.Parameters.Keys}} | Export-CliXml .\2010.xml
Once the XML files have been created I imported them back using the Import-CliXml cmdlet and then processed the differences with the compare.ps1 script.
When the script completes it exports the changes to the compare.xml file in the script's directory.
The objects version of the script defines four properties for each command:
- Name - The name of the command.
- State- Determines if the command is new to Exchange 2010. Possible values:
New - New command in 2010.
Removed - The command doesn't exist in 2010.
Blank - Command exists in both versions of Exchange, look for changes in the NewParameters or RemovedParameters properties - NewParameters - A list of new parameters.
- RemovedParameters - A list of removed parameters.
The script and xml files can be downloaded from HERE. Make sure to extract all files to a single directory before you run the script.
Examples:
# Get all removed commands
$compare | Where-Object {$_.State –eq ‘removed’}
# Get all new commands
$compare | Where-Object {$_.State –eq ‘new}
# Get a list of removed parameters for cmdlets that exists in Exchange 2007 and 2010
$compare | Where-Object {!$_.State -AND $_.RemovedParameters} | Select-Object Name,RemovedParameters
Windows PowerShell provides several cmdlets to trace various low-level PowerShell components. When tracing, components generate detailed messages about each step in its internal processing. Developers use the trace data to monitor data flow, program execution, and errors. Tracing is mostly for developers but they are available to all users.
The following shows the output of Trace-Command using its first help code example (for more information about the Trace-Command cmdlet, type: Get-Help Trace-Command -Full):
Trace-Command expects two pieces of information, one or more trace sources and an expression (enclosed in braces). We can get a list of trace sources by using the Get-TraceSource cmdlet:
PS > Get-TraceSource
Options Name Listeners Description
------- ---- --------- -----------
None SingleShell {Default} SingleShell
None MshSnapinLoadUnload {Default} Loading and unloading mshsnapins
None MshConsoleInfo {Default} MshConsoleInfo object that is constructed from...
None PSSnapInInfo {Default} PSSnapInInfo
None PSSnapInReader {Default} PSSnapInReader
None RunspaceConfigura... {Default} RunspaceConfigurationEntryCollection
(...)
However, sometimes it is not so obvious which source we need to use to trace a specific component (cmdlet). That's why I wrote the Get-CommandTraceSource function. Give it a command name (cmdlet) and Get-CommandTraceSource will get you back the command's PSTraceSource object (if implemented).
#Requires -Version 2.0
function Get-CommandTraceSource
{
param(
[Parameter(Position=0, Mandatory=$true, ValueFromPipeline=$true)]
[System.String]$Command
)
process
{
try
{
$c = Get-Command $Command -CommandType Cmdlet
$c.ImplementingType.GetField("tracer","Static,NonPublic").GetValue($null)
}
catch
{
throw
}
}
}
# Example
PS > Get-CommandTraceSource -Command Start-Job
Options Name Listeners Description
------- ---- --------- -----------
None JobCmdlets {Default} Job related cmdlets
Here's a one-liner that outputs all cmdlets trace sources:
PS > Get-Command -CommandType Cmdlet | Add-Member ScriptProperty TraceSource {$this.ImplementingType.GetField("tracer","Static,NonPublic").GetValue($null).Name} -PassThru | Where-Object {$_.TraceSource} | Select-Object Name,TraceSource
Name TraceSource
---- -----------
Add-Computer AddComputer
Add-Member AddMember
Checkpoint-Computer CheckpointComputer
Clear-EventLog ClearEventLog
Compare-Object CompareObject
ConvertFrom-StringData ConvertFromStringData
ConvertTo-Html ConvertToHtml
Disable-ComputerRestore DisableComputerRestore
Enable-ComputerRestore EnableComputerRestore
Export-Alias AliasCommands
Export-ModuleMember Parser
Export-PSSession ExportPSSessionCommand
ForEach-Object Parser
Get-Acl GetAclCommand
Get-Command GetCommandCmdlet
Get-ComputerRestorePoint GetComputerRestorePoint
Get-Credential CredentialCommands
Get-EventLog GetEventLog
Get-Help GetHelpCommand
Get-HotFix GetHotFix
Get-PfxCertificate CertificateCommands
Get-PSSession GetPSSession
Get-Random GetRandomCommand
Get-Unique GetUnique
Get-WmiObject TransactionCommands
Group-Object GroupObjectCommand
Import-Alias AliasCommands
Import-LocalizedData ImportLocalizedData
Import-PSSession ImportPSSessionCommand
Invoke-Expression InvokeExpressionCommand
Invoke-WmiMethod TransactionCommands
Limit-EventLog LimitEventLog
Measure-Command MeasureCommandCommand
Measure-Object MeasureObject
New-EventLog NewEventLog
New-Object NewObjectCommand
New-PSSession NewPSSession
New-PSSessionOption NewPSSessionOption
New-TimeSpan NewTimeSpanCommand
New-WebServiceProxy StartProcess
Out-Default OutDefaultCommand
Out-File OutFileCommand
Out-GridView format_out_OutGridViewCommand
Out-Host OutHostCommand
Read-Host HostCmdlets
Remove-Computer RemoveComputer
Remove-EventLog RemoveEventLog
Remove-Module Parser
Remove-PSSession RemovePSSessionCommand
Remove-WmiObject TransactionCommands
Reset-ComputerMachinePassword ResetComputerMachinePassword
Restart-Computer RestartComputer
Restore-Computer RestoreComputer
Select-Object SelectObject
Select-String SelectStringCommand
Set-Acl SetAclCommand
Set-Date SetDateCommand
Set-ExecutionPolicy ExecutionPolicyCommands
Set-PSBreakpoint SetPSBreakpoint
Set-PSDebug Parser
Set-WmiInstance TransactionCommands
Show-EventLog ShowEventLogCommand
Sort-Object SortObject
Start-Job JobCmdlets
Start-Process StartProcess
Start-Sleep StartSleepCommand
Start-Transcript StartTranscriptCommand
Stop-Computer StopComputer
Stop-Transcript StopTranscriptCommand
Tee-Object TeeObject
Test-Connection TestConnection
Update-FormatData UpdateFormatDataCommand
Update-TypeData UpdateTypeDataCommand
Where-Object Parser
Write-Debug WriteDebugCommand
Write-EventLog WriteEventLog
Write-Output WriteOutputCommand
Write-Progress WriteProgressCommand
Write-Verbose WriteVerboseCommand
Write-Warning WriteWarningCommand
See Also:
Set-TraceSource