Skip to content

Error in detect-reboot script #32

@hotzenwalder

Description

@hotzenwalder

The script used to detect the last time a system was restarted gives an error on my Windows 10 build (19045.2728 Dutch)
https://github.com/JayRHa/EndpointAnalyticsRemediationScripts/blob/main/Toast-RebootMessage/detect-reboot.ps1

The error is
`
Cannot convert value "1680444208,84456" to type "System.Int32". Error: "De indeling van de invoertekenreeks is onjuist."
At line:1 char:1

  • $diff = $now - $poweron`

It's triggered by the command $diff = $now - $poweron, but the problem is probably related to the values of $now and $poweron.
The returned values in the original script are

1680444208,84456 for $now and 1680444197,71884 for $differ.

If you replace the , with a . by changing the $now and $differ to these commands, it works.

$now = (Get-Date -UFormat "%s" -Date (Get-Date)) -replace (",",".")
$poweron = (Get-Date -UFormat "%s" -Date (Get-Process -Id $pid).StartTime) -replace (",",".")

New values are 1680444208.84456 for $now and 1680444197.71884 for $differ and then the calculations work.

I think it has something to do with the region we run in our enviroment Windows (Dutch), so the characters used for numbering might differ.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions