Why is Get-MessageTraceV2 Not Recognized?
Asked by
accent+88
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?
Answers
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.
Reply to this answer
Have you tried reinstalling the module using the `-AllowClobber` switch? It might resolve any conflicts with existing cmdlets.
Reply to this answer
If the `-AllowClobber` option didn't work, maybe uninstall the module completely and then reinstall it. Sometimes starting from scratch can help.
Reply to this answer
Gotcha! Just curious, are other cmdlets like `Get-Mailbox` working fine for you, or are you running into issues with those too?
Reply to this answer
Add your answer
Answers are reviewed before publication.
Related Discussions