Issue
Code backup
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
$app = "PS - User Catch"
|
||||
$ver = "v 0.3"
|
||||
|
||||
$start = "Stai eseguendo:"
|
||||
$exec = "Lo script $app e' in esecuzione."
|
||||
|
||||
Write-Host $start, $app, $ver
|
||||
Write-Host $exec -fore green
|
||||
|
||||
$UserCatch = (180..200) | % {
|
||||
$Ip = "172.16.82.$_";
|
||||
$Status = test-connection -computername "$ip" -quiet -count 1;
|
||||
|
||||
$StatusOut = switch ($Status) {
|
||||
'True' {"True"}
|
||||
'False' {"`0"}
|
||||
}
|
||||
|
||||
if ($Status -like 'True') {
|
||||
|
||||
$GetHostname = Resolve-DnsName $ip -ErrorAction Ignore |select -exp NameHost;
|
||||
|
||||
$QueryUser = if ($GetHostname -like 'PC*') {
|
||||
foreach ($s in $GetHostname){
|
||||
foreach($ServerLine in @(query user /server:$s) -split"\n")
|
||||
{
|
||||
$Parsed_Server = $ServerLine -split"\s+"
|
||||
|
||||
$Parsed_Server[1]
|
||||
$Parsed_Server[4]
|
||||
$Parsed_Server[6]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Write-output "`n$IP`t$StatusOut`t$GetHostname"
|
||||
|
||||
if ($GetHostname -like 'PC*') {
|
||||
Write-Output "`n$QueryUser`n"
|
||||
}
|
||||
}
|
||||
else {
|
||||
"`0"
|
||||
}
|
||||
}
|
||||
|
||||
Start-Transcript -Path .\testlog.txt
|
||||
|
||||
Write-Host $UserCatch
|
||||
|
||||
Stop-Transcript
|
||||
Reference in New Issue
Block a user