Reserved disk space on the root partition in Linux
Các hệ thống linux sử dụng file system như ext4,ext3-2 mặc định dành ra 5% disk cho phân vùng root. Việc này nhằm đảm bảo người quản trị còn có […]
Các hệ thống linux sử dụng file system như ext4,ext3-2 mặc định dành ra 5% disk cho phân vùng root. Việc này nhằm đảm bảo người quản trị còn có […]
Umask là gì thì xem lại bài này Umask là gì Câu hỏi này nếu thi LPI sẽ bị hỏi, mình note ra đây để ghi nhớ cho bản thân. […]
Script tìm và disable các account không đăng nhập trong vòng 90 ngày trên AD
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# disableUsers.ps1 # Set msDS-LogonTimeSyncInterval (days) to a sane number. By # default lastLogonDate only replicates between DCs every 9-14 # days unless this attribute is set to a shorter interval. # Also, make sure to create the EventLog source before running, or # comment out the Write-EventLog lines if no event logging is # needed. Only needed once on each machine running this script. # New-EventLog -LogName Application -Source "DisableUsers.ps1" # Remove "-WhatIf"s before putting into production. Import-Module ActiveDirectory $inactiveDays = 90 $neverLoggedInDays = 90 $disableDaysInactive=(Get-Date).AddDays(-($inactiveDays)) $disableDaysNeverLoggedIn=(Get-Date).AddDays(-($neverLoggedInDays)) # Identify and disable users who have not logged in in x days $disableUsers1 = Get-ADUser -Filter {Enabled -eq $TRUE} -Properties lastLogonDate, whenCreated, distinguishedName | Where-Object {($_.lastLogonDate -lt $disableDaysInactive) -and ($_.lastLogonDate -ne $NULL)} $disableUsers1 | ForEach-Object { Disable-ADAccount $_ #Write-EventLog -Source "DisableUsers.ps1" -EventId 9090 -LogName Application -Message "Attempted to disable user $_ because the last login was more than $inactiveDays ago." } # Identify and disable users who were created x days ago and never logged in. $disableUsers2 = Get-ADUser -Filter {Enabled -eq $TRUE} -Properties lastLogonDate, whenCreated, distinguishedName | Where-Object {($_.whenCreated -lt $disableDaysNeverLoggedIn) -and (-not ($_.lastLogonDate -ne $NULL))} $disableUsers2 | ForEach-Object { Disable-ADAccount $_ #Write-EventLog -Source "DisableUsers.ps1" -EventId 9091 -LogName Application -Message "Attempted to disable user $_ because user has never logged in and $neverLoggedInDays days have passed." } |