Active Directory Administration
This page is dedicated to any and all Active Directory administration
Get Active Win10 Machine Patch Level (Last Logon in 60 Days)
$LastLogon = (Get-Date).Adddays( -(60) ); $Workstations = Get-ADComputer -Filter { LastLogonTimeStamp -gt $LastLogon -and OperatingSystem -like 'Windows 10'} -Properties *; $Workstations = $Workstations | Select-Object -Property DNSHostname,OperatingSystem,OperatingSystemVersion,IPv4Address,LastLogonDate,DistinguishedName,SID; Export-Results -Output $Workstations -Path "C:\Users\burmat\Desktop\Workstations.csv"Get Hosts Last Logon
Import-Module ActiveDirectory
function Get-ADHostsLastLogon() {
$hnames = Get-ADComputer -Filter 'ObjectClass -eq "Computer"' | Select -Expand Name
foreach ($hname in $hnames) {
$dcs = Get-ADDomainController -Filter {Name -like "*"}
$time = 0
foreach($dc in $dcs) {
$computer = Get-ADComputer $hname | Get-ADObject -Properties lastLogon
if($computer.LastLogon -gt $time) {
$time = $computer.LastLogon
}
}
$dt = [DateTime]::FromFileTime($time).ToString('g')
# 12/31/1600 will result if $time = 0 (never logged on before)
Write-Host $dt", " $hname
}
Write-Host "Done."
}
Get-ADHostsLastLogonGet Users Last Logon
Get Stale Hosts
Move Object to Retire OU
Disable Everything in OU
FILE SYSTEM ADMINISTRATION
Getting Directory Sizes
Tail a File
MISC CLEANUP / MANAGEMENT
Clear Cached (MsCacheV2) Credentials
Last updated