Powershell script to detect connected IP on a router

I want to know the IP of a computer without a display which connected to a router, use below powershell script to detect. I don’t have the admin access of the router.

1
2
3
4
5
6
7
8
for ($i=1; $i -lt 255; $i++) {
$computer = '192.168.1.' + $i
if (Test-Connection -ComputerName $computer -Count 1 -Quiet) {
Write-Host "$computer is online."
} else {
Write-Host "$computer"
}
}