Hi @Михаил Андросов ,
maybe this helps to get your requirement done:
$dateTime = (Get-Date).AddDays(-380) # Get Date - x days - for testing
$threshold = (Get-Date).AddDays(-365) # define threshold for "old" in - x days
# here we go
$a = $dateTime |
Select-Object Date,@{ Name = 'isOld' ; Expression = { If ($_ -lt $threshold ) {$true} else {$false}} }
$a
And here your script ( Not tested by myself !!! ):
$threshold = (Get-Date).AddDays(-365) # define threshold for "old" in - x days
Get-AdComputer -properties -filter |
Select-Object Name,OperatingSystem,OperatingSystemVersion,LastLogonDate,@{ Name = 'isOld' ; Expression = { If ($_.LastLogonDate -lt $threshold ) {$true} else {$false}} } |
Out-File -Encoding utf8 -FilePath "C:\Downloads\computers.txt"
----------
(If the reply was helpful please don't forget to upvote and/or accept as answer, thank you)
Regards
Andreas Baumgarten