Hi ZohebShaikh .
Thank you for the script but when executing i am having this error:
Could you please help! Cheers, Mark
It is failing on the line:
$Certexpirydate = [datetime](Get-date $importall[$i].'Certificate Expiration Date' -Format $formatdata)
The error I am getting is as follows:
Cannot convert value "28/06/2023 15:04" to type "System.DateTime". Error: "String was not recognized as a valid DateTime."
At line:123 char:6
+ $Certexpirydate = [datetime](Get-date $importall[$i].'Certificat ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvalidCastParseTargetInvocationWithFormatProvider
Cannot convert value "28/06/2023 15:12" to type "System.DateTime". Error: "String was not recognized as a valid DateTime."
At line:123 char:6
+ $Certexpirydate = [datetime](Get-date $importall[$i].'Certificat ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvalidCastParseTargetInvocationWithFormatProvider
Cannot convert value "27/10/2023 16:02" to type "System.DateTime". Error: "String was not recognized as a valid DateTime."
At line:123 char:6
+ $Certexpirydate = [datetime](Get-date $importall[$i].'Certificat ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvalidCastParseTargetInvocationWithFormatProvider