Using PowerShell to Discover Who Added a Client to Your Domain

Using PowerShell to Discover Who Added a Client to Your Domain
In this video, PowerShell instructor Jason Yoder shows how to use PowerShell to quickly find who added a new client to your domain.
For instructor-led PowerShell courses, see our course schedule.
Download the PowerShell script used in this video.
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 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | <# ╔══════════════════════════════════════════════════════════════════════════════╗ ║ ║ ║ Discovering Who Added a Client to Your Domain ║ ╟──────────────────────────────────────────────────────────────────────────────╢ ║ Interface Technical Training ║ ║ Jason A Yoder ║ ║ ║ ╚══════════════════════════════════════════════════════════════════════════════╝ #> # ms-DS-MachineAccountQuota Documentation Start-Process -FilePath "https://msdn.microsoft.com/en-us/library/ms678639(v=vs.85).aspx" # List the current value of ms-DS-MachineAccountQuota Get-ADDomain | Select-Object -ExpandProperty DistinguishedName | Get-ADObject -Properties 'ms-DS-MachineAccountQuota' | Select-Object -ExpandProperty ms-DS-MachineAccountQuota # Join a client to the domain as DWilliams (Diane Williams) # List the most recently joined client to the domain Get-ADComputer -Filter * | Select-Object -Last 1 # Check for all computer objects with an ms-DS-CreatorSid populated. Get-ADComputer -Properties ms-ds-CreatorSid -Filter {ms-ds-creatorsid -ne "$Null"} # ms-DS-CreatorSid Documentation Start-Process -FilePath "https://msdn.microsoft.com/en-us/library/ms678637(v=vs.85).aspx" # Number clients and users in this environment Get-ADComputer -Filter * | Measure-Object | Select-Object -ExpandProperty Count Get-ADUser -Filter * | Measure-Object | Select-Object -ExpandProperty Count # Assuming it takes 10 seconds to evaluate all of the records (In Days). ((10 * (Get-ADComputer -Filter * | Measure-Object | Select-Object -ExpandProperty Count)) + (10 * (Get-ADUser -Filter * | Measure-Object | Select-Object -ExpandProperty Count)))/60/60/24 # Who did this? $Clients = Get-ADComputer -Properties ms-ds-CreatorSid, WhenCreated -Filter {ms-ds-creatorsid -ne "$Null"} $Users = Get-ADUser -Filter * ForEach ($C in $Clients) { ForEach ($U in $Users) { If ($U.Sid -eq $C.'ms-ds-creatorsid') { $C | Select-Object -Property @{ Name = 'ComputerName'; Expression = {$C.Name}}, @{Name = 'WhenCreated'; Expression = {$C.WhenCreated.DateTime}}, @{Name = "UserName"; Expression = {$U.Name} } } } } # Get the ms-DS-MachineAccountQuota object from Active Directory. $Attribute = Get-ADDomain | Select-Object -ExpandProperty DistinguishedName | Get-ADObject -Properties 'ms-DS-MachineAccountQuota' # Expand the attribute. $Attribute # Replace the value of ms-DS-MachineAccountQuota from 10 to 0. Set-ADObject -Identity $Attribute.ObjectGUID -Replace @{'ms-DS-MachineAccountQuota' = 0} # Validate the change. Get-ADDomain | Select-Object -ExpandProperty DistinguishedName | Get-ADObject -Properties 'ms-DS-MachineAccountQuota' |
You May Also Like
get aduser, Get-ADComputer, Get-ADDomain, Get-ADObject, PowerShell troubleshooting
A Simple Introduction to Cisco CML2
0 3668 0Mark Jacob, Cisco Instructor, presents an introduction to Cisco Modeling Labs 2.0 or CML2.0, an upgrade to Cisco’s VIRL Personal Edition. Mark demonstrates Terminal Emulator access to console, as well as console access from within the CML2.0 product. Hello, I’m Mark Jacob, a Cisco Instructor and Network Instructor at Interface Technical Training. I’ve been using … Continue reading A Simple Introduction to Cisco CML2
How to Build in a PSMethod to your PowerShell Code
0 66 0In this video, PowerShell instructor Jason Yoder shows how to add Methods (PSMethod) to your code using free software that’s added into the PSObject. For instructor-led PowerShell courses, see our course schedule. Microsoft Windows PowerShell Training Download the Building Methods PowerShell script</a> used in this video. <# ╔══════════════════════════════════════════════════════════════════════════════╗ ║ ║ ║ Building Methods ║ ╟──────────────────────────────────────────────────────────────────────────────╢ … Continue reading How to Build in a PSMethod to your PowerShell Code
Configuring Windows Mobility Center and How to Turn it On and Off
1 1404 1Video transcription Steve Fullmer: In our Windows training courses, we often share information about the Windows 8.1 Mobility Center. Mobility Center was introduced for mobile and laptop devices in Windows 7. It’s present and somewhat enhanced in Windows 8. Since we don’t have mobile devices in our classrooms, I decided to take a little bit … Continue reading Configuring Windows Mobility Center and How to Turn it On and Off