Skip to content

New-MgUserEvent ignores timeZone when not in interactive session #3223

@TWRene

Description

@TWRene

Describe the bug

Following Script is used:

`$Event = @{
subject = "Out of Office"
start = @{
dateTime = "$2025-03-14T00:00:00"
timeZone = "UTC"
}
end = @{
dateTime = "$2025-03-16T00:00:00"
timeZone = "UTC"
}
location = @{
displayName = "Out of Office"
}
body = @{
contentType = "HTML"
content = ""
}
attendees = @()
isAllDay = $true
showAs = "oof"
}

New-MgUserEvent -UserId $UserId -BodyParameter $Event`

When i use it in an interactive Seccion of Powershell ISE, Powershell 5.1 and Powershell 7.4, it creates a correct event.

When the same Script is used Powershell Runbook (in Azure and on Remoteworker), in an interactive administrative Session of Powershell or in Start-Process -FilePath ....., it ignores any datetime or setup of timezones and creates an half hour event, starting in the next 1-29 minutes.

Even when isAllDay is set to $false and try to set an Event for like an hour, it shows the same behavior.

Expected behavior

should not ignore timezone setting

How to reproduce

See issue report

SDK Version

No response

Latest version known to work for scenario above?

No response

Known Workarounds

none

Debug output

Click to expand log ```
</details>


### Configuration

_No response_

### Other information

_No response_

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions