Issue
Code backup
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
$app = 'PS - User Catch'
|
||||
$ver = 'v 0.1'
|
||||
|
||||
Write-Host $app, $ver,"`n UserCatch"
|
||||
|
||||
$SweepIp = (193..198) | % {
|
||||
$Ip="172.16.82.$_";
|
||||
$Status=test-connection -computername "$ip" -quiet -count 1;
|
||||
|
||||
$StatusOut = switch ($Status) {
|
||||
'True' {"True"}
|
||||
'False' {"`0"}
|
||||
}
|
||||
|
||||
$GetHostname=Resolve-DnsName $ip -ErrorAction Ignore |select -exp NameHost;
|
||||
|
||||
$QueryUser=if ($StatusOut -like 'True'){
|
||||
if ($GetHostname -like 'PC*'){
|
||||
(query user /server:$GetHostname) -split "`n" -replace '\s\s+', ';' | convertfrom-csv -Delimiter ';'
|
||||
}
|
||||
}
|
||||
|
||||
Write-output "`n$IP `t $StatusOut `t $GetHostname"
|
||||
if ($GetHostname -like 'PC*'){
|
||||
Write-Output "`n$QueryUser"
|
||||
}
|
||||
}
|
||||
|
||||
Write-Host $SweepIp
|
||||
Reference in New Issue
Block a user