Important Notice: On February 29th, this community was put into read-only mode. All existing posts will remain but customers are unable to add new posts or comment on existing. Please feel to join our Community Discord for any questions and discussions.

Deployment with WoL > shutdown only of machines which have been woken up

I admit Im not really good with scripts and powershell. But my colleague is. But hes not very much into deployment. So before talking to him I wanted to ask if any of you have implemented an option where after deployment machines got shut down. But only machines which have been woken up by WoL through PDQ. Machines which were already turned on before deployment need to stay turned on. This would be for Dell machines. Thanks!


Date Votes
  • That's an interesting question. I'm not sure how to check if a computer was WoL, but you could look into querying the computer uptime with PowerShell, and then shut it down if the uptime is less than 5 minutes. That's just an example and may not work well for your use-case/environment. I recommend testing all code before deploying.

  • $OS = Get-CimInstance win32_operatingsystem

    # Get the time 5 minutes ago
    $MinutesAgo = (Get-Date).AddMinutes(-5)

    # Compare the time 5 minutes ago with the boot time
    if ($OS.LastBootUpTime -GT $MinutesAgo){
    Restart-Computer -Force