Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Date format #3

Open
sleewharry opened this issue Aug 15, 2022 · 8 comments
Open

Date format #3

sleewharry opened this issue Aug 15, 2022 · 8 comments
Assignees
Labels
bug Something isn't working

Comments

@sleewharry
Copy link

hello,
It seems that tool can not recognize share creation date. Error is:
[*][08/15/2022 12:41] - Identified top 5 share names.
Cannot convert value "16.07.2016 8:04:24 AM" to type "System.DateTime". Error: "String was not recognized as a valid DateTime."

thanks!

@nullbind nullbind self-assigned this Aug 18, 2022
@nullbind nullbind added the bug Something isn't working label Aug 18, 2022
@nullbind
Copy link
Collaborator

nullbind commented Aug 24, 2022

Hey @sleewharry,

Thanks for the call out! I have not run into that in the lab or during testing. Can you tell me what version of Windows and PowerShell you are running?

@sleewharry
Copy link
Author

Hi @nullbind
OS: Windows 10 Version 2004 (OS Build 19041.450)
PS: 5.1.19041.1

This is the line that PS is complaining about:
$ExPrivCreationLastn = $ExcessiveSharePrivs | Where-Object {([Datetime]$_.CreationDate.trim() -ge $StartDateAccess -and [Datetime]$_.CreationDate.trim() -le $EndDateAccess)}

2022-08-24 15_46_56-Window

@Moonbeam4520
Copy link
Contributor

Hello, I have the exact same problem, I don't know a lot about powershell but it looks like an issue about the locale

Impossible de convertir la valeur « 26/08/2022 10:32:46 » en type « System.DateTime ». Erreur : « La chaîne n'a pas été reconnue en tant que DateTime valide. »
Au caractère Ligne:4844 : 54
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument : (:) [], RuntimeException
    + FullyQualifiedErrorId : InvalidCastParseTargetInvocationWithFormatProvider

@jegillet-debug
Copy link

Hello,
I've modified ligne 553 to 568 and added the following code to the date to string conversion
"{0:MM/dd/yyyy HH:mm:ss}" -f

This seem to have made the trick on my computer that mix french and english language, I am sure there is a better way to do it.

                  # Creation date
                  $CreationdDateObject = Get-Item "\\$TargetAsset\$CurrentShareName" -ErrorAction SilentlyContinue | Select CreationTime
                  $CreationdDate = ("{0:MM/dd/yyyy HH:mm:ss}" -f ($CreationdDateObject.CreationTime)).ToString()
                  $CreationdDateYear = $CreationdDateObject.CreationTime.Year.ToString()

                  # Last modified date
                  $TargetPath = $_.Path
                  $LastModifiedDateObject = Get-Item "\\$TargetAsset\$CurrentShareName" -ErrorAction SilentlyContinue | Select-Object LastWriteTime
                  $LastModifiedDate = ("{0:MM/dd/yyyy HH:mm:ss}" -f ($LastModifiedDateObject.LastWriteTime)).ToString()
                  $LastModifiedDateYear  = $LastModifiedDate.split(' ')[0].split('/')[2]

                  # Last accessed date
                  $TargetPath = $_.Path
                  $LastAccessDateObject = Get-Item "\\$TargetAsset\$CurrentShareName" -ErrorAction SilentlyContinue | Select-Object LastAccessTime
                  $LastAccessDate = ("{0:MM/dd/yyyy HH:mm:ss}" -f ($LastAccessDateObject.LastAccessTime)).ToString()
                  $LastAccessDateYear = $LastAccessDate.split(' ')[0].split('/')[2]

@Cool34000
Copy link

Hi,

Thanks @jegillet-debug: the fix is working for me too (French locale)

@nullbind
Copy link
Collaborator

nullbind commented Jun 1, 2023

Hey Everyone,

I'll try to get that fixed in the near future. Thanks for reaching out and sharing the solution!

@LOLCATATONIA
Copy link

LOLCATATONIA commented Sep 7, 2023

Danish locals here. Windows 11. PowerShell 7.3.6

Cannot convert value "26-04-2023 13:29:31" to type "System.DateTime". Error: "String was not recognized as a valid DateTime."
At (...path...)\PowerHuntShares.psm1:4844 char:54
+ ... ere-Object {([Datetime]$_.LastAccessDate.trim() -ge $startDate -and [ ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvalidCastParseTargetInvocationWithFormatProvider

@Indigo744
Copy link

Still an issue, French locale here...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

7 participants