Cum dezactivezi calculatoarele care nu au mai comunicat cu domeniul?

Configurare noua (How To)

Situatie

Vrei sa dezactivezi calculatoarele care nu au mai avut nicio activtate de mai mult de 180 de zile.

Solutie

Pasi de urmat

Rulezi Powershell pe serverul de Active Directory

$DaysInactive = 180 
$time = (Get-Date).Adddays(-($DaysInactive))
get-adcomputer -filter {((LastLogonTimeStamp -lt $time) -or (LastLogonTimeStamp -notlike "*"))} -SearchBase "OU=name,OU=name,DC=win,DC=org,DC=TLD"`
 -Properties CN,name,LastLogonDate,*|
        foreach {
            Set-ADComputer -Identity $_ -Enabled $false
            $_
                }|
         sort LastLogonDate -Descending | 
         ft name,ipv4address,LastLogonDate |
         Out-File $homeDesktophost180.txt

Tip solutie

Permanent

Voteaza

(0 out of 0 people found this article helpful)

Despre Autor

Leave A Comment?