locked
Is there a way to turn on a remote PC? RRS feed

  • Question

  • Hello, my remote PC is down and i want to turn it on somehow, the bad thing

    is i don't have local access to it, i tried to use wakemeonlan freeware but they request

    a mac address,i also don't know it's mac address.

    Soemone know a way of doing this?

    thank you

    Saturday, February 22, 2014 1:01 PM

Answers

  • Hi I think the only way you can turn on a remote machine is if machine has a IDrac card or you have a software on LAN which can poweron the machine. But you need to remote dail in to the network first.

    Is there no one at the remote site how can turn the machine on for you?

    Saturday, February 22, 2014 1:14 PM
  • If the computer is turned off you have no way to power it back on unless you have some of of lights out management, i.e. Intel AMT, Wake-on-Lan, ILO etc. 

    It sounds like you don't have any of these so you won't be able to turn it on remotely. 

    For old style wake on LAN your network needs to be able to support it and you may need to be in the same area as your computer to do it - depending on your routers and switches. 

    Sorry it looks like you will have to get someone to manually power it back on for you. 


    Regards,

    Denis Cooper

    MCITP EA - MCT

    Help keep the forums tidy, if this has helped please mark it as an answer

    My Blog

    LinkedIn:

    Saturday, February 22, 2014 6:38 PM

All replies

  • Hi I think the only way you can turn on a remote machine is if machine has a IDrac card or you have a software on LAN which can poweron the machine. But you need to remote dail in to the network first.

    Is there no one at the remote site how can turn the machine on for you?

    Saturday, February 22, 2014 1:14 PM
  • I'd get in touch with the hardware manufacturer on this request.

     

     

     


    Regards, Dave Patrick ....
    Microsoft Certified Professional
    Microsoft MVP [Windows]

    Disclaimer: This posting is provided "AS IS" with no warranties or guarantees , and confers no rights.

    Saturday, February 22, 2014 1:24 PM
  • I can't contact them, it's impossible, they don't give me an answer.

    There is no one who can turn on my machine

    Saturday, February 22, 2014 6:35 PM
  • If the computer is turned off you have no way to power it back on unless you have some of of lights out management, i.e. Intel AMT, Wake-on-Lan, ILO etc. 

    It sounds like you don't have any of these so you won't be able to turn it on remotely. 

    For old style wake on LAN your network needs to be able to support it and you may need to be in the same area as your computer to do it - depending on your routers and switches. 

    Sorry it looks like you will have to get someone to manually power it back on for you. 


    Regards,

    Denis Cooper

    MCITP EA - MCT

    Help keep the forums tidy, if this has helped please mark it as an answer

    My Blog

    LinkedIn:

    Saturday, February 22, 2014 6:38 PM
  • Then you might check the web site for the pc or mobo manufacturer.

     

     

     


    Regards, Dave Patrick ....
    Microsoft Certified Professional
    Microsoft MVP [Windows]

    Disclaimer: This posting is provided "AS IS" with no warranties or guarantees , and confers no rights.

    Saturday, February 22, 2014 9:55 PM
  • Hi,

    Do you need any other assistance? Can you share latest update with us?

    Thanks,
    Dharmesh
    Tuesday, February 25, 2014 4:09 AM
  • Hi,

    In our network remote desktop users are registered in a database with username and computername.

    When a user successfully logs on to the RD Gateway, a program retrieves the computername registered with this user and sends a WOL-request to that computer. This program is setup as an event trigger for NPS event 6278: Network Policy Server granted full access to a user because the host met the defined health policy.

    Because of other requirements the WOL-request is actually issued calling a web REST service on a management server which then checks if the computer is accessible and sends a WOL packet if the computer is down. But, network configuration as to which systems can send WOL broadcast packets aside, it is possible to send WOL packets from a RD Gateway server. On the management server we use a PowerShell script that services the REST requests and perform the actual sending of WOL packet's.

    Now the problem we're left with is: how can we inform a connecting user that the computer to connect to is powered down and has been sent a Wake On LAN. This is somewhat of a problem because the time spend performing WOL is usually longer than RD connection timeout.

    Anyhow, this is the code for the event trigger program:

    Imports System.Data.SqlClient
    Imports System.IO
    
    Module Main
        ' TriggerWOL - Event ID 6278 trigger: request Wake On LAN
        ' (c) 2014 ing. Paul van der Elst, ISSC, Leiden University
        '
        Dim xmlCacheFilename As String = Environment.CommandLine.Replace(Chr(34), "").Trim
        Dim tblCache As New DataTable
        Dim log As String = ""
        Const RDGWQUERY As String = "SELECT Computername, Username FROM <..data table..> WHERE Active='True'"
    
        Sub Main()
    
            xmlCacheFilename = xmlCacheFilename.Substring(0, xmlCacheFilename.LastIndexOf("\")) & "\RDGatewayAccess.xml"
    
            fillTableCache()
    
            ' 1. read Security EventLog eventid 6278 events that occured in the past 2 minutes
            ' 2. check for valid username in eventlog data
            ' 3. get computer(s) from database table
            ' 4. call RESTwol on wol-server
    
            Dim UsersAccessing As New List(Of String)
            Dim ComputersToStart As New List(Of String)
            GetEvent6278Users(UsersAccessing)
            For Each aUser As String In UsersAccessing
                GetComputers(aUser, ComputersToStart)
            Next
            For Each aComputer As String In ComputersToStart
                RESTwol(aComputer)
            Next
    
            Dim Logfilename As String = xmlCacheFilename.Replace("RDGatewayAccess.xml", "TriggerWOL.log")
            If (Date.Now - File.GetLastWriteTime(xmlCacheFilename)).Hours > 11 Then
                WriteCache()
            End If
            If My.Settings.Log Then
                If File.Exists(Logfilename) Then
                    ' keep 7 days log
                    If (Date.Now - File.GetCreationTime(Logfilename)).Days > 7 Then
                        File.Delete(Logfilename)
                        Threading.Thread.Sleep(250)
                    End If
                End If
                Using LogWriter As StreamWriter = File.AppendText(Logfilename)
                    LogWriter.Write(log)
                    LogWriter.Close()
                End Using
            End If
        End Sub
        Sub GetEvent6278Users(ByRef Users As List(Of String))
            Dim securityEventLog As New EventLog("Security", ".")
            Dim eIndex As Long = securityEventLog.Entries.Count - 1
            Dim aEvent As EventLogEntry = securityEventLog.Entries(eIndex)
            Dim asOf As Date = Date.Now
            asOf = asOf.AddMinutes(-1 * (My.Settings.eventSearchMinutes))
    
            While eIndex > 0 And aEvent.TimeWritten >= asOf
                If aEvent.InstanceId = 6278 Then
                    Dim aUser As String = extractUsernameFromEventData(aEvent.Message)
                    If aUser <> "" Then
                        Users.Add(aUser)
                    End If
                End If
                eIndex -= 1
                aEvent = securityEventLog.Entries(eIndex)
            End While
            If My.Settings.Log Then log += Environment.NewLine
        End Sub
        Function extractUsernameFromEventData(eMessage As String) As String
            Dim i As Integer = eMessage.IndexOf("Account Name:")
            Dim retval As String = ""
            If i > 0 And eMessage.Length > i + 14 Then
                retval = eMessage.Substring(i + 13)
                i = retval.IndexOf(vbNewLine)
                If i > 0 And retval.IndexOf("$") < 0 Then
                    retval = retval.Substring(0, i)
                    i = retval.IndexOf("\")
                    If i > 0 Then retval = retval.Substring(i + 1)
                Else
                    retval = ""
                End If
            End If
            Return retval.Trim
        End Function
        Sub GetComputers(ByVal User As String, ByRef Computers As List(Of String))
    
            For Each aRow As DataRow In tblCache.Select("Username='" & User & "'")
                If Computers.IndexOf(aRow.Item("Computername")) < 0 Then Computers.Add(aRow.Item("Computername"))
            Next
    
        End Sub
        Sub RESTwol(computer As String)
            Dim RESTuri As String = "http://" & My.Settings.WOLserver
            Dim Responsestring As String = ""
            Dim tmWol As Date = Date.Now
            Dim msWol As Integer = 0
    
            RESTuri += ":" & My.Settings.WOLserviceport
            RESTuri += "/RESTwol/" & computer
            Dim RESTServiceRequest As Net.HttpWebRequest = TryCast(Net.WebRequest.Create(RESTuri), Net.HttpWebRequest)
            RESTServiceRequest.KeepAlive = False
            RESTServiceRequest.Method = "GET"
    
            Dim RESTServiceResponse As Net.HttpWebResponse
            Try
                RESTServiceResponse = TryCast(RESTServiceRequest.GetResponse(), Net.HttpWebResponse)
                Dim RESTResponseStreamReader As New IO.StreamReader(RESTServiceResponse.GetResponseStream())
                Responsestring = RESTResponseStreamReader.ReadToEnd
                RESTResponseStreamReader.Close()
                RESTResponseStreamReader.Dispose()
                RESTServiceResponse.Close()
                msWol = (Date.Now - tmWol).Milliseconds
                log += Date.Now.ToString & " computer: " & computer & ", wol-status: " & Responsestring & ", wol delay: " & msWol & "ms" & Environment.NewLine
            Catch ex As Exception
                log += Date.Now.ToString & " RESTwol error: " & ex.Message & Environment.NewLine
            End Try
        End Sub
        Sub fillTableCache()
            ' cache the data base table to be able to handle requests if the database is temporary down
            Try
                Dim WSLogConnection = New SqlClient.SqlConnection(My.Settings.WSLogConnectionstring)
                WSLogConnection.Open()
                Dim command As New SqlClient.SqlCommand(RDGWQUERY, WSLogConnection)
                Dim adapter As SqlDataAdapter = New SqlDataAdapter()
                adapter.SelectCommand = command
                adapter.Fill(tblCache)
                tblCache.TableName = "RDGatewayAccess"
                adapter.Dispose()
                command.Dispose()
                WSLogConnection.Close()
                WSLogConnection.Dispose()
    
            Catch ex As Exception
                log += Date.Now.ToString & " fillTableCache error: " & ex.Message & " fallback to cache: " & xmlCacheFilename & Environment.NewLine
                Dim CacheDataset As New DataSet
                CacheDataset.ReadXml(xmlCacheFilename)
                tblCache = CacheDataset.Tables(0)
            End Try
        End Sub
        Sub WriteCache()
            Try
                Dim WSLogConnection = New SqlClient.SqlConnection(My.Settings.WSLogConnectionstring)
                WSLogConnection.Open()
                Dim command As New SqlClient.SqlCommand(RDGWQUERY, WSLogConnection)
                Dim adapter As SqlDataAdapter = New SqlDataAdapter()
                adapter.SelectCommand = command
                Dim table As New DataTable
                adapter.Fill(table)
                table.TableName = "RDGatewayAccess"
                If My.Computer.FileSystem.FileExists(xmlCacheFilename) Then My.Computer.FileSystem.DeleteFile(xmlCacheFilename)
                table.WriteXml(xmlCacheFilename)
                table.Clear()
                table.Dispose()
                adapter.Dispose()
                command.Dispose()
                WSLogConnection.Close()
                WSLogConnection.Dispose()
    
            Catch ex As Exception
                log += Date.Now.ToString & " WriteCache error: " & ex.Message & Environment.NewLine
            End Try
        End Sub
    End Module
     

    and a sample WOL powershell script:

        param($computername)
        [int] $Packets=2
        [int] $UDPportnumber=65535
        [int] $counter = 0
        [int] $CountDots = 1
        [int] $wait = 10
     
        #function for sending UDP client packages
        function Send-Packet([string]$MacAddress, [int]$Packets, [string]$IPSubnet)
        {
         	try 
        	{
         	$Broadcast = [System.Net.IPAddress]::Parse($IPSubnet)
        	
        	## Create UDP client instance
         	$UdpClient = New-Object Net.Sockets.UdpClient
        		
        	## Create IP endpoints for each port
        	$IPEndPoint1 = New-Object Net.IPEndPoint $Broadcast, $UDPportnumber
    
        	## Construct physical address instance for the MAC address of the machine (string to byte array)
        	$MAC = [Net.NetworkInformation.PhysicalAddress]::Parse($MacAddress)
    
        	## Construct the Magic Packet frame
        	$Frame = [byte[]]@(255,255,255, 255,255,255)
         	$Frame += ($MAC.GetAddressBytes()*16)
    
        	## Broadcast UDP packets to the IP endpoints of the machine
        		for($i = 0; $i -lt $Packets; $i++) {
        			$UdpClient.Send($Frame, $Frame.Length, $IPEndPoint1) | Out-Null
        			sleep 1;
        		}
             }
             catch
             {
    #             write-host $Error;
             }
         }
    Kind regards, Paul

     


    PE




    Saturday, March 1, 2014 6:22 PM