I require a AD powershell one liner that will return all active computers (lastlogonate > 30 days).
$inactive = (Get-Date).AddDays(-30)
Get-ADComputer -filter {lastlogondate -gt $inactive }
I can do the above but I ideally need a one liner to include in a framework that executes a list of queries. I thought the below would work:
Get-ADComputer -filter {lastlogondate -gt $(Get-Date).AddDays(-30) }
But I get an error "...value of argument "path" is not valid"