Skip to content

Commit

Permalink
Update Bootstrap-RemoteHostViaSSH.ps1
Browse files Browse the repository at this point in the history
Added snippet to scan network for printers
  • Loading branch information
pldmgg authored Nov 2, 2023
1 parent 6416051 commit 5a1a6ad
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions MyScripts/Bootstrap-RemoteHostViaSSH.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -333,3 +333,21 @@ $PromptSSParams = @{
RemovePwdFile = $False
}
$UserString = Prompt-ActiveUserForSecureString @PromptSSParams

# Scan network for Printers
$printers = 1..254 | ForEach-Object {
$ip = "192.168.5.$_"
$tcpClient = New-Object System.Net.Sockets.TcpClient
$result = $tcpClient.BeginConnect($ip, 9100, $null, $null)

if ($result.AsyncWaitHandle.WaitOne(1000, $false) -and $tcpClient.Connected) {
$tcpClient.Close()
[PSCustomObject]@{
IP = $ip
Status = 'Printer Found'
}
} else {
$tcpClient.Close()
$null
}
} | Where-Object { $_.Status -eq 'Printer Found' }

0 comments on commit 5a1a6ad

Please sign in to comment.