Why is Get-MessageTraceV2 Not Recognized?

0
2
Asked By CuriousCoder42 On

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

Answered By PowerShellExpert On

Gotcha! Just curious, are other cmdlets like `Get-Mailbox` working fine for you, or are you running into issues with those too?

Answered By ScriptingNinja On

If the `-AllowClobber` option didn't work, maybe uninstall the module completely and then reinstall it. Sometimes starting from scratch can help.

Answered By TechWhiz123 On

Have you tried reinstalling the module using the `-AllowClobber` switch? It might resolve any conflicts with existing cmdlets.

Answered By Samphis On

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

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.