The Purpose
A fellow MVP mentioned that he noticed that the workload cmdlets from CU5 and before were missing from Exchange and after investigating I wrote an article on this. Then it dawned on me that if Microsoft followed their previous practices for deprecating cmdlets, I should be able to search for it. So basically the script gets a list of all the commands that pertain to Exchange. Then the script will loop through each command. It runs a get-help -full and looks for the word ‘deprecated’ if present. First iteration of the script:
$commands = (get-command | where {$_.modulename -eq "<server name>"}).name foreach ($line in $commands) { $result = get-help $line -full $result if ($result -like "*deprecated*") { write-host "$line is going to be deprecated!" -foregroundcolor yellow } else { # write-host "$line is not going to be deprecated!" -foregroundcolor green } }
The warning message will appear like this:
If the word is not there, the results will look more like this:
However, I noticed I was getting inaccurate results. Apparently the “-like” switch seems to search the last part of the variable and would not find anything if the word was in the first part of the variable. So I re-wrote the script:
The Script
The re-write stored the help as a txt file and then searches that file for the criteria. However, this criteria does produce some false positives as well, namely if a feature is deprecated and not the entire PowerShell cmdlets. Here is the code as is:
$commands = (get-command | where {$_.modulename -eq "lab02-ex01.lab2.local"}).name foreach ($line in $commands) { get-help $line -full > c:\downloads\command.txt $search = Select-String -Path c:\downloads\command.txt -pattern "cmdlet will be removed in a future version of" $search2 = Select-String -Path c:\downloads\command.txt -pattern "cmdlet has been deprecated" if ($search -ne $null) { write-host "$line is going to be deprecated!" -foregroundcolor yellow } if ($search2 -ne $null) { write-host "$line is going to be deprecated!" -foregroundcolor yellow } remove-item c:\downloads\command.txt }
Any result means the cmdlet or a switch is deprecated.
Here is what we are looking for in the get-help of the cmdlets:
and something like this as well:
As a working example, I ran this in my lab, which is Exchange 2013 SP1. I found these commands were either deprecated or going to deprecated:
- Enable-AntispamUpdates
- Clear-ActiveSyncDevice
- Clear-ActiveSyncDevice
- Get-ActiveSyncMailboxPolicy
- Get-ActiveSyncDevice
- Get-ActiveSyncMailboxPolicy
- Get-TransportServer
- New-ActiveSyncMailboxPolicy
- Set-ActiveSyncMailboxPolicy
- Set-TransportServer
This script can be run on any version of Exchange 2013.