Forum Discussion
TJCooper440
Oct 16, 2024Copper Contributor
Powershell 7 - $time is not defined - Script from Microsoft
I get the error "Get-ADComputer: Variable: 'time' found in expression: $time is not defined.". The script is straight from Microsoft and $time is populated with a date/time. It seems very simple, I d...
TJCooper440
Oct 21, 2024Copper Contributor
This is the original code. I added the $_. before lastlogintimestamp.
Active Directory: How to Find Inactive Computers in | Microsoft Learn
$DaysInactive = 90
$time = (Get-Date).Adddays(-($DaysInactive))
Get-ADComputer -Filter {LastLogonTimeStamp -lt $time} -ResultPageSize 2000 -resultSetSize $null -Properties Name, OperatingSystem, SamAccountName, DistinguishedName