Install and Run Windows Powershell
Give yourself unrestricted script access:
Set-ExecutionPolicy Unrestricted
Make a list of IPs to query and put it in a text file (1 IP per line).
Modify script below and put it in a text file with extension .ps1 (like script.ps1)
$ErrorActionPreference = 'SilentlyContinue'
$computers = Get-Content g:scriptipaddress.txt
foreach($computer in $computers) {
$ping = Test-Connection -ComputerName $computer -Count 1 -Quiet
$computerName = [system.net.dns]::Resolve("$computer")
#$hostname = $computerName.HostName
$shortHostname = $computerName.HostName.Split(".")[0]
if ($ping -eq 'True')
{
$UserName = (Get-WmiObject -ComputerName $computer win32_ComputerSystem).UserName
Write-Host "$shortHostname $UserName" -ForegroundColor Green
#Write-Host "$hostname is pingable" -ForegroundColor Green
}
else
{
Write-Host "$computer is not pingable" -ForegroundColor Red
}
}
Put the .txt and the.ps1 in the same folder.
Browse to the folder in Powershell.
Type .script.ps1
Wait for the query to find all the logged in users on your IP range…
from
Power ping and get computer, username