none
PowerShell Reboot Members Of A Group RRS feed

  • Question

  • I am trying to reboot servers that are a in a security group. This is the script I have so far:

    $ListOfServers = Get-ADGroupMember "Reboot Group" | Expand-Property Name
    
    ForEach ($Server in $ListOfServers)
    {
        Restart-Computer -ComputerName $Server
    }
    The error I get is: "Restart-Computer: Computer Name @{Name=WSUS} cannot be resolved with the exception: A non-recoverable error occurred during a database lookup"

    Can someone tell me what I'm doing wrong please?
    Tuesday, October 28, 2014 7:42 AM

Answers

  • Get-ADGroupMember 'Reboot Group' | 
        ForEach-Object{
            Restart-Computer -ComputerName $_.Name
        }
    


    ¯\_(ツ)_/¯

    Tuesday, October 28, 2014 8:10 AM

All replies

  • Get-ADGroupMember 'Reboot Group' | 
        ForEach-Object{
            Restart-Computer -ComputerName $_.Name
        }
    


    ¯\_(ツ)_/¯

    Tuesday, October 28, 2014 8:10 AM
  • Get-ADGroupMember 'Reboot Group' | 
        ForEach-Object{
            Restart-Computer -ComputerName $_.Name
        }
    


    ¯\_(ツ)_/¯


    Thanks. Nice and simple answer.
    Wednesday, October 29, 2014 2:06 AM
  • This should work too:

    (Get-ADGroupMember 'Reboot Group').Name | Restart-Computer


    ¯\_(ツ)_/¯

    Wednesday, October 29, 2014 4:16 AM