Find logged in users on Windows subnet

Asphyxia

Owner
Administrator
Apr 25, 2015
1,844
2
2,197
327
Want to skip the whole clocking in to work..

Cool, let's use PowerShell instead with asynchronous pings!!

Let's say we have 172.1.1.1... and all employees connect within this range.

At 8:10 AM we can run a scheduled task to ping all our guys, eh? All computers should be shutting down overnight.. or laptops coming and going. Otherwise people pinged at midnight could be talked to, eh?

This is going to be based off https://ciphers.pw/threads/scanning-windows-network-for-defense-rapidly.8130/ - but you do not need to go there.

Code:
if(Test-Path -path .\TestConnectionAsync.psm1){
#Good, continue
}else{
wget https://gallery.technet.microsoft.com/scriptcenter/Multithreaded-PowerShell-0bc3f59b/file/114248/1/TestConnectionAsync.psm1 -OutFile TestConnectionAsync.psm1
Import-Module .\TestConnectionAsync.psm1
Write-Host "Downloaded the asynchronous pinging module."
}

$FormatEnumerationLimit =-1
$ipnet = Read-Host -Prompt 'Enter the range to scan all 1-255 for example 10.10.10 '
Add-Content targets.txt "Touch"
Clear-Content targets.txt

for($second = 1; $second -lt 256; $second++){
Add-Content targets.txt "$ipnet.$second"
}

Get-Content .\targets.txt | Test-ConnectionAsync -MaxConcurrent 100 -Quiet | findstr "True" > living.txt

Long story short, you could do something like this:

Code:
Get-ADComputer -Filter { samAccountName -like "*office*" }

Then with all those results, I would ping all the hostnames of the ADComputer employees in the office for example. Any questions? Please ask.. tried to make this simple. :D

You could also remove the user input aspect to fully automate this to keep track of who is signed in, and what times!?
 
Top