Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Dliv3/2c2c544b3b81357c04e2f55cc4843613 to your computer and use it in GitHub Desktop.
Save Dliv3/2c2c544b3b81357c04e2f55cc4843613 to your computer and use it in GitHub Desktop.
Gets a list of AD computers that were created by regular users exercising their default right to create up to 10 computer accounts in an AD domain
$machineAccountQuotaComputers = Get-ADComputer -filter {ms-DS-CreatorSID -ne "$null"} -Properties ms-DS-CreatorSID,Created
foreach ($machine in $machineAccountQuotaComputers) {
$creator = $null
try {
$creator = [System.Security.Principal.SecurityIdentifier]::new($machine.'ms-DS-CreatorSID').Translate([System.Security.Principal.NTAccount]).Value
}
catch {
$creator = $machine.'ms-DS-CreatorSID'
}
New-Object psobject -Property @{
Name = $machine.Name
DistinguishedName = $machine.DistinguishedName
Creator = $creator
Created = $machine.Created
} | Select-Object Name,DistinguishedName,Creator,Created | Sort-Object -Property Created
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment