Git Product home page Git Product logo

Comments (5)

12Knocksinna avatar 12Knocksinna commented on August 16, 2024 1

This is difficult because I can't see the data you're dealing with. I've updated the script again. If you find another issue, please tell me the value of the date retrieved from Export-MailboxDiagnosticLogs.

BTW, because you have all the PowerShell code, you can debug and fix the problem yourself...

from office365itpros.

12Knocksinna avatar 12Knocksinna commented on August 16, 2024

Just make sure that the data being compared is a date. I've updated the script to do this.

from office365itpros.

albert-widjaja avatar albert-widjaja commented on August 16, 2024

Thank you for the quick update @12Knocksinna , however it is still doesn't work for the Non US time zone?


Get-Date : Cannot bind parameter 'Date'. Cannot convert value "7/18/2023 5:01:47 AM" to type "System.DateTime". Error: "String was not recognized as a valid DateTime."
At C:\ReportUnusedExOMailboxes.PS1:34 char:50
+         [datetime]$LastActiveDateTime = Get-Date $LastActive
+                                                  ~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [Get-Date], ParameterBindingException
    + FullyQualifiedErrorId : CannotConvertArgumentNoMessage,Microsoft.PowerShell.Commands.GetDateCommand
 
New-TimeSpan : Cannot bind parameter 'Start' to the target. Exception setting "Start": "Cannot convert null to type "System.DateTime"."
At C:\ReportUnusedExOMailboxes.PS1:35 char:49
+ ...   $DaysSinceActive = (New-TimeSpan -Start $LastActiveDateTime -End $N ...
+                                               ~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : WriteError: (:) [New-TimeSpan], ParameterBindingException
    + FullyQualifiedErrorId : ParameterBindingFailed,Microsoft.PowerShell.Commands.NewTimeSpanCommand
 

PS C:\Windows\system32\WindowsPowerShell\v1.0>  $LastActive
7/18/2023 5:01:47 AM

PS C:\Windows\system32\WindowsPowerShell\v1.0> $LastActiveDateTime

PS C:\Windows\system32\WindowsPowerShell\v1.0> (New-TimeSpan -Start $LastActiveDateTime -End $Now).Days
New-TimeSpan : Cannot bind parameter 'Start' to the target. Exception setting "Start": "Cannot convert null to type "System.DateTime"."
At line:1 char:22
+ (New-TimeSpan -Start $LastActiveDateTime -End $Now).Days
+                      ~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : WriteError: (:) [New-TimeSpan], ParameterBindingException
    + FullyQualifiedErrorId : ParameterBindingFailed,Microsoft.PowerShell.Commands.NewTimeSpanCommand

from office365itpros.

12Knocksinna avatar 12Knocksinna commented on August 16, 2024

Try the script now

from office365itpros.

albert-widjaja avatar albert-widjaja commented on August 16, 2024

Thank you for the quick response @12Knocksinna ,

even after I've updated the -0 into 0, there is still an error thrown like the below at line 36:

image

from office365itpros.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.