mirror of
https://github.com/Auties00/Reboot-Launcher.git
synced 2026-01-13 11:12:23 +01:00
41 lines
1.2 KiB
PowerShell
41 lines
1.2 KiB
PowerShell
[cmdletbinding(
|
|
DefaultParameterSetName = '',
|
|
ConfirmImpact = 'low'
|
|
)]
|
|
Param(
|
|
[Parameter(
|
|
Mandatory = $True,
|
|
Position = 0,
|
|
ParameterSetName = '',
|
|
ValueFromPipeline = $True)]
|
|
[String]$computer,
|
|
[Parameter(
|
|
Position = 1,
|
|
Mandatory = $True,
|
|
ParameterSetName = '')]
|
|
[Int16]$port
|
|
)
|
|
Process {
|
|
$udpobject = new-Object system.Net.Sockets.Udpclient
|
|
$udpobject.client.ReceiveTimeout = 2000
|
|
$udpobject.Connect("$computer", $port)
|
|
$a = new-object system.text.asciiencoding
|
|
$byte = $a.GetBytes("$( Get-Date )")
|
|
[void]$udpobject.Send($byte, $byte.length)
|
|
$remoteendpoint = New-Object system.net.ipendpoint([system.net.ipaddress]::Any, 0)
|
|
Try
|
|
{
|
|
$receivebytes = $udpobject.Receive([ref]$remoteendpoint)
|
|
[string]$returndata = $a.GetString($receivebytes)
|
|
If ($returndata)
|
|
{
|
|
exit 0
|
|
}
|
|
}
|
|
Catch
|
|
{
|
|
$udpobject.close()
|
|
exit 1
|
|
}
|
|
}
|