I'm updating a script for pulling message traces in Exchange Online, and I've been told that the old Get-MessageTrace cmdlet will be deprecated soon. I need to switch to Get-MessageTraceV2, but every time I try to run it, I get an error saying the command isn't recognized.
Here's the script I'm using:
```powershell
# Connect to Exchange Online
Connect-ExchangeOnline -ShowBanner:$False
# Set dates for the mail trace
$startDate = (Get-Date).AddDays(-7).ToString("MM/dd/yyyy")
$endDate = (Get-Date).ToString("MM/dd/yyyy")
# Parameters for mail trace
$params = @{
StartDate = $startDate
EndDate = $endDate
SenderAddress = "[email protected]"
Status = "Failed"
}
Get-MessageTraceV2 @params
```
I've confirmed that I have the ExchangeOnlineManagement module 3.8 installed, which should support this cmdlet since it was introduced in version 3.7. But when I try `Get-Command Get-MessageTraceV2`, I get the same 'not recognized' error. Even when I search with `Get-Command *V2`, I only see cmdlets for Microsoft.Graph, nothing related to ExchangeOnlineManagement.
I've also attempted uninstalling and reinstalling the module, and tested it on a fresh system without the module installed. What am I missing?
4 Answers
Gotcha! Just curious, are other cmdlets like `Get-Mailbox` working fine for you, or are you running into issues with those too?
If the `-AllowClobber` option didn't work, maybe uninstall the module completely and then reinstall it. Sometimes starting from scratch can help.
Have you tried reinstalling the module using the `-AllowClobber` switch? It might resolve any conflicts with existing cmdlets.
I did try that, but it still doesn’t show up. I also installed PowerShell 7, but the cmdlet is still missing. Turns out there’s a prerelease of version 3.9; I’ll give that a shot next.
Related Questions
How To: Running Codex CLI on Windows with Azure OpenAI
Set Wordpress Featured Image Using Javascript
How To Fix PHP Random Being The Same
Why no WebP Support with Wordpress
Replace Wordpress Cron With Linux Cron
Customize Yoast Canonical URL Programmatically