Get-CalendarDiagnosticLog : A parameter cannot be found that matches parameter name 'StartTime'.. issue

Shamyog 1 Reputation point
2023-03-23T21:44:58.3066667+00:00

I am trying to use the below script, but it gets an error:

# Import the ExchangeOnlineManagement module
Import-Module ExchangeOnlineManagement

# Connect to Exchange Online
Connect-ExchangeOnline -Credential $cred

# Get the conference rooms
$rooms = Get-Mailbox -RecipientTypeDetails RoomMailbox

# Set the start and end times for the query
$startDate = (Get-Date).AddDays(-7).ToString('yyyy-MM-ddTHH:mm:ss')
$endDate = (Get-Date).ToString('yyyy-MM-ddTHH:mm:ss')

# Loop through each conference room
foreach ($room in $rooms) {
    # Get the meetings for the room in the past 30 days
    $meetings = Get-CalendarDiagnosticLog -Identity $room.PrimarySmtpAddress -StartTime $startDate -EndTime $endDate

    # Loop through each meeting and output the details to a CSV file
    foreach ($meeting in $meetings) {
        $output = [PSCustomObject]@{
            ResourceName = $room.Name
            Organizer = $meeting.Organizer
            Duration = ($meeting.EndTime - $meeting.StartTime).TotalMinutes
            Date = $meeting.StartTime.ToShortDateString()
        }
        $output | Export-Csv -Path "C:\output.csv" -Append -NoTypeInformation
    }
}

# Disconnect from Exchange Online
Disconnect-ExchangeOnline

Are above script correct? I am getting below error

Get-CalendarDiagnosticLog : A parameter cannot be found that matches parameter name 'StartTime'.
At line:17 char:78
+ ... arDiagnosticLog -Identity $room.PrimarySmtpAddress -StartTime $startD ...
+                                                        ~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [Get-CalendarDiagnosticLog], ParameterBindingException
    + FullyQualifiedErrorId : NamedParameterNotFound,Get-CalendarDiagnosticLog
Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,355 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Limitless Technology 43,926 Reputation points
    2023-03-24T11:41:23.1+00:00

    Hello there,

    Usually in the PowerShell script, the error “A parameter cannot be found that matches parameter name ‘xxx’.” is because the parameter name is not a known parameter of the cmdlet. Please check whether the relevant script is correct.

    To help narrow this issue, please check the following tips:

    Run this PowerShell local to check if this issue still exists.

    Please check if other versions of Powershell could run successful without this warning.

    How do you configure the service connection, it would be much better that you could share the detailed repro steps with screenshots.

    Hope this resolves your Query !!

    --If the reply is helpful, please Upvote and Accept it as an answer–

    0 comments No comments