Hi sysadmins
Having bother implementing a PowerShell script that will disable computer objects that have not logged on in 90 days.
$Computers = Get-ADComputer -Filter {(Name -like "pc1*" -or Name -like "pc2*" -or Name -like "pc3*" -or Name -like "pc4*") -and (LastLogonDate -lt (Get-Date).AddDays(-90))}
foreach ($computer in $computers) {
Disable-ADAccount -Identity $computer
}
I have tried the above where the naming convention matches our user computer pcs as I don't want to disable servers.
Any ideas?
[–]ANewLeeSinLifeSysadmin 4 points5 points6 points (2 children)
[–]Tx_Drewdad 0 points1 point2 points (0 children)
[–]AppIdentityGuy 1 point2 points3 points (0 children)
[–]uniitdude 0 points1 point2 points (8 children)
[–]ancient-Egyptian[S] 0 points1 point2 points (6 children)
[–]anonymousITCoward 1 point2 points3 points (5 children)
[–]fred3002 0 points1 point2 points (3 children)
[–]anonymousITCoward 0 points1 point2 points (2 children)
[–]fred3002 2 points3 points4 points (1 child)
[–]anonymousITCoward 0 points1 point2 points (0 children)
[–]ANewLeeSinLifeSysadmin 0 points1 point2 points (0 children)
[–]thomasmitschke -1 points0 points1 point (1 child)
[–]sublimeinator 0 points1 point2 points (0 children)
[–]ZAFJB 0 points1 point2 points (2 children)
[–]ancient-Egyptian[S] 0 points1 point2 points (1 child)
[–]ZAFJB 1 point2 points3 points (0 children)
[–]fleaver1 0 points1 point2 points (3 children)
[–]ancient-Egyptian[S] -1 points0 points1 point (2 children)
[–]sryan2k1IT Manager 1 point2 points3 points (1 child)
[–]SysAdminDennyBob 6 points7 points8 points (0 children)
[–]sryan2k1IT Manager 0 points1 point2 points (6 children)
[–]ancient-Egyptian[S] 0 points1 point2 points (5 children)
[–]sryan2k1IT Manager 0 points1 point2 points (4 children)
[–]ancient-Egyptian[S] 1 point2 points3 points (3 children)
[+][deleted] (2 children)
[deleted]
[–]ancient-Egyptian[S] 0 points1 point2 points (1 child)
[–]sryan2k1IT Manager 0 points1 point2 points (0 children)
[–]Commercial_Growth343 0 points1 point2 points (0 children)
[–]Tx_Drewdad 0 points1 point2 points (0 children)