Я пытаюсь этот код
Get-ADUser -Properties whenCreated -Filter {samaccountname -like 'A*'} |
Select-Object @{n='FullName';e={$_.Name}},@{n='UserName';e={$_.SamaccountName}},@{n='CreateDate';e={$_.WhenCreated}} |
Export-Csv -path c:\userexport.csv -NoTypeInformation -Delimiter ';' -Encoding UTF8
Import-Csv -Path c:\userexport.csv -Delimiter ';' |
Where-Object {[datetime]::parseexact($_.'CreatedDate','dd/MM/yyyy HH:mm:ss',$null) -le (Get-Date).AddYears(-2)} |
Select-Object FullName
но я получил ошибку:
Ayman Ledawi aymanle 19/12/2010 13:08:35
Ayoub Hassan ayoubha 12/11/2012 16:00:38
Azure ADConnect AzADConnect 24/10/2019 12:02:01
Azriel Perel Prof azrielpe 19/02/2003 15:27:50
Azuretest1 azuretest1 27/05/2019 14:40:11
Azuretest2 azuretest2 27/05/2019 14:42:33
Azuretest3 Azuretest3 27/05/2019 14:43:34
Azuretest4 azuretest4 27/05/2019 14:44:52
Exception calling "ParseExact" with "3" argument(s): "String was not recognized as a valid DateTime."
At line:11 char:17
+ ... ere-Object {[datetime]::parseexact($_.'When was Created','dd/MM/yyyy ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : FormatException
Exception calling "ParseExact" with "3" argument(s): "String was not recognized as a valid DateTime."
At line:11 char:17
+ ... ere-Object {[datetime]::parseexact($_.'When was Created','dd/MM/yyyy ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : FormatException
Exception calling "ParseExact" with "3" argument(s): "String was not recognized as a valid DateTime."
At line:11 char:17
+ ... ere-Object {[datetime]::parseexact($_.'When was Created','dd/MM/yyyy ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : FormatException
Exception calling "ParseExact" with "3" argument(s): "String was not recognized as a valid DateTime."
At line:11 char:17
+ ... ere-Object {[datetime]::parseexact($_.'When was Created','dd/MM/yyyy ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : FormatException