For this Quick PowerShell, I wanted to share a script that I wrote that will scan Get-Help of a particular PowerShell module for a particular phrase. I wrote this as a labor of love as I was looking for some information on cmdlets that were incomplete (Security and Compliance Center) or deprecated (Exchange Server). The script will prompt for credentials for remote connections to Office 365.
The Code
Here is the script code I am using for my examples:
# Phase Check in Powershell Help
Function SCCConection {
$LiveCred = Get-Credential
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.compliance.protection.outlook.com/powershell-liveid/ -Credential $LiveCred -Authentication Basic -AllowRedirection
Import-PSSession $Session
# Clear Screen
CLS
Write-Host "What phrase would you like to search for in the help for cmdlets in the " -ForegroundColor White -NoNewline
Write-Host "Security and Compliance Center" -ForegroundColor Green -NoNewline
Write-Host "? " -ForegroundColor White
$Pattern = Read-Host
$Counter = 0
$ModuleName = (Get-Module | where {$_.ModuleType -eq "Script"}).name
Foreach ($Name in $ModuleName) {
If ($Name -like "tmp*") {
$Commands = Get-command | Where {$_.ModuleName -eq $Name}
Write-host ' '
Write-host ' '
Write-host ' '
Write-host ' '
Write-host ' '
Write-host ' '
$TotalItems = ($Commands).Count
Write-Host "The Get-Help for these cmdlets contains the phrase - " -ForegroundColor Green -NoNewline
Write-Host "$Pattern" -ForegroundColor Green
Write-Host "------------------------------------------------------------------------" -ForegroundColor Green
Foreach ($Line in $Commands) {
# Added progress bar
$Counter++
$Percent = $Counter/$TotalItems
$I = [math]::Round($Percent,4)*100
Write-Progress -Activity "Search in Progress" -Status "$I% Complete:" -PercentComplete $I
# Search Get-Help for the pattern
Get-Help $Line -Full > c:\downloads\command.txt
$search = Select-String -Path c:\downloads\command.txt -pattern $Pattern
If ($search -ne $null) {
# write-host "$line contains the phrase " -ForegroundColor White -NoNewline
# Write-host "$Search" -foregroundcolor yellow -NoNewLine
# Write-host " in the Get-Help of the cmdlet." -ForegroundColor White
Write-Host "$Line" -ForegroundColor Yellow
}
Remove-item c:\downloads\command.txt
}
}
}
} # End function SCCConection
Function EOPConnection {
$LiveCred = Get-Credential
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.protection.outlook.com/powershell-liveid/ -Credential $LiveCred -Authentication Basic -AllowRedirection
Import-PSSession $Session
# Clear Screen
CLS
Write-Host "What phrase would you like to search for in the help for cmdlets in " -ForegroundColor White -NoNewline
Write-Host "Exchange Online? " -ForegroundColor Green -NoNewline
Write-Host "? " -ForegroundColor White -NoNewline
$Pattern = Read-Host
$Counter = 0
$ModuleName = (Get-Module | where {$_.ModuleType -eq "Script"}).name
Foreach ($Name in $ModuleName) {
If ($Name -like "tmp*") {
$Commands = Get-command | Where {$_.ModuleName -eq $Name}
Write-host ' '
Write-host ' '
Write-host ' '
Write-host ' '
Write-host ' '
Write-host ' '
$TotalItems = ($Commands).Count
Write-Host "The Get-Help for these cmdlets contains the phrase - " -ForegroundColor Green -NoNewline
Write-Host "$Pattern" -ForegroundColor Green
Write-Host "------------------------------------------------------------------------" -ForegroundColor Green
Foreach ($Line in $Commands) {
# Added progress bar
$Counter++
$Percent = $Counter/$TotalItems
$I = [math]::Round($Percent,4)*100
Write-Progress -Activity "Search in Progress" -Status "$I% Complete:" -PercentComplete $I
# Search Get-Help for the pattern
Get-Help $Line -Full > c:\downloads\command.txt
$search = Select-String -Path c:\downloads\command.txt -pattern $Pattern
If ($search -ne $null) {
Write-Host "$Line" -ForegroundColor Yellow
}
Remove-item c:\downloads\command.txt
}
}
}
} # End function EOPConnection
Function ExOConnection {
$LiveCred = Get-Credential
# $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/powershell/ -Credential $LiveCred -Authentication Basic -AllowRedirection
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $LiveCred -Authentication Basic -AllowRedirection
Import-PSSession $Session
# Clear Screen
CLS
Write-Host "What phrase would you like to search for in the help for cmdlets in " -ForegroundColor White -NoNewline
Write-Host "Exchange Online Protection" -ForegroundColor Green -NoNewline
Write-Host "? " -ForegroundColor White -NoNewline
$Pattern = Read-Host
$Counter = 0
$ModuleName = (Get-Module | where {$_.ModuleType -eq "Script"}).name
Foreach ($Name in $ModuleName) {
If ($Name -like "tmp*") {
$Commands = Get-command | Where {$_.ModuleName -eq $Name}
Write-host ' '
Write-host ' '
Write-host ' '
Write-host ' '
Write-host ' '
Write-host ' '
$TotalItems = ($Commands).Count
Write-Host "The Get-Help for these cmdlets contains the phrase - " -ForegroundColor Green -NoNewline
Write-Host "$Pattern" -ForegroundColor Green
Write-Host "------------------------------------------------------------------------" -ForegroundColor Green
Foreach ($Line in $Commands) {
# Added progress bar
$Counter++
$Percent = $Counter/$TotalItems
$I = [math]::Round($Percent,4)*100
Write-Progress -Activity "Search in Progress" -Status "$I% Complete:" -PercentComplete $I
# Search Get-Help for the pattern
Get-Help $Line -Full > c:\downloads\command.txt
$search = Select-String -Path c:\downloads\command.txt -pattern $Pattern
If ($search -ne $null) {
Write-Host "$Line" -ForegroundColor Yellow
}
Remove-item c:\downloads\command.txt
}
}
}
} # End function ExOConnection
Function LocalExchangeConnection {
# Clear Screen
CLS
Write-Host "What phrase would you like to search for in the help for cmdlets on this " -ForegroundColor White -NoNewline
Write-Host "Exchange Server" -ForegroundColor Green -NoNewline
Write-Host "? " -ForegroundColor White -NoNewline
# Variables for the function
$Pattern = Read-Host
$Counter = 0
$Name = ([System.Net.Dns]::GetHostByName(($env:computerName))).hostName
$Commands = Get-command | Where {$_.ModuleName -eq $Name}
Write-host ' '
Write-host ' '
Write-host ' '
Write-host ' '
Write-host ' '
Write-host ' '
$TotalItems = ($Commands).Count
Write-Host "The Get-Help for these cmdlets contains the phrase - " -ForegroundColor Green -NoNewline
Write-Host "$Pattern" -ForegroundColor Green
Write-Host "------------------------------------------------------------------------" -ForegroundColor Green
Foreach ($Line in $Commands) {
# Added progress bar
$Counter++
$Percent = $Counter/$TotalItems
$I = [math]::Round($Percent,4)*100
Write-Progress -Activity "Search in Progress" -Status "$I% Complete:" -PercentComplete $I
# Search Get-Help for the pattern
Get-Help $Line -Full > c:\downloads\command.txt
$search = Select-String -Path c:\downloads\command.txt -pattern $Pattern
If ($search -ne $null) {
Write-Host "$Line" -ForegroundColor Yellow
}
Remove-item c:\downloads\command.txt
}
} # End function LocalExchangeConnection
$Menu = {
Write-Host " "
Write-Host " "
Write-Host " "
Write-Host " ***********************************************" -ForegroundColor Cyan
Write-Host " Phrase Search - PowerShell - Whervere" -ForegroundColor Cyan
Write-Host " ***********************************************" -ForegroundColor Cyan
Write-Host " "
Write-Host " 1) Security and Compliance Center"
Write-Host " 2) Exchange Online"
Write-Host " 3) Exchange Online Protection"
Write-Host " 4) Exchange Server (local)"
Write-host " "
Write-Host " 99) Exit" -ForegroundColor Red
Write-Host " "
Write-Host " Select an option.. [1-99]? " -ForegroundColor White -NoNewLine
}
#################
## Script Body ##
#################
CLS
Do {
Invoke-Command -ScriptBlock $Menu
$Choice = Read-Host
Switch ($Choice) {
1 {
SCCConection
}
2 {
EOPConnection
}
3 {
ExOConnection
}
4 {
LocalExchangeConnection
}
99 {# Exit
Popd
Write-Host "Exiting..." -ForegroundColor Yellow
write-host "Closing PowerShell sessions to Office 365......." -ForegroundColor Green
Get-PSSession | Remove-PSSession
}
Default {Write-Host "You haven't selected any of the available options. "}
}
} while ($Choice -ne 99)
Script Run Throughs / Real World Results
To show what this script can do in the real world, I put some screenshots below of the real world searches I performed just before I posted this blog article:
Exchange Server
In this search, I wanted to look for cmdlets that, in the Get-Help, contained the word ‘deprecated’ to look for cmdlets that were scheduled to be removed from Exchange 2016 and later. Here is the sample run (not completed yet):

Security and Compliance Center
Now, for this example, I wanted to look for cmdlets that were incomplete in their Get-Help. The phrase I was searching for was ‘Insert example’. This phrase would discover cmdlets that were missing proper examples. Now, this doesn’t mean that there were not other relevant phrases to look for when looking for incomplete cmdlets, but this phrase would reveal many cmdlets:

Exchange Online and EOP
Currently in my tenant, Get-Help appears to be broken for Exchange Online and Exchange Online Protection and thus I do not have any screenshots from those workloads quite yet.
