Closed altamiro closed 3 years ago
Dates are always annoying to deal with as timezones come into play here. Could you try the following
statistics = PowerShell(pool)
statistics.add_script('''
$actionTime = @(Get-MailboxStatistics -Identity $args[0] | Select-Object LastUserActionTime)
$actionTime[0].LastUserActionTime.GetType().FullName
$actionTime''').add_argument(_PrimarySmtpAddress)
output_statistics = statistics.invoke()
print(output_statistics[0]) # The type output
print(output_statistics[1]._xml) # Contains the CLIXML returned from the server
My guess is the datetime has a timezone and that's automatically being converted to universal time so the UTC date is in the future compared to your local time.
error message
The syntax is not supported by this runspace. This can occur if the runspace is in no-language mode.
My apologies I should have realised that with Exchange by now. Try just
statistics = PowerShell(pool)
statistics.add_cmdlet("Get-MailboxStatistics")
statistics.add_parameter("Identity", _PrimarySmtpAddress)
statistics.add_cmdlet("Select-Object").add_argument(["LastUserActionTime"])
output_statistics = statistics.invoke()[0]
print(output_statistics) # The type output
print(output_statistics._xml) # Contains the CLIXML returned from the server
This I already do, but it generates a change in the return of the date. As explained in my first comment. So it works, but then I return to the same problem. Through PowerShell, the date is '2020-12-18' and via pypsrp is '2020-12-19'.
The key part is the print(output_statistics._xml)
line as that will print out the CLIXML of the raw object returned by PowerShell. We can use that to determine the type that PowerShell is returning and why it's printing the way it does in your test.
Closing due to no further information being received.
When I execute the command "Get-mailboxstatistics Identity $ _. PrimarySmtpAddress | select LastUserActionTime" via the poweshell directly the value of the field comes the date value. Ex. '2020-12-18'
When I use the code below. It returns the same field but adding another day. Ex. '2020-12-19'
have any idea what it might be?
Thanks!