Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 8583

reboot a list of servers and output results to file.

$
0
0

I am new to powershell and i am trying to write a simple script that will reboot a list of machines (XP, and 7) and input the results of the reboots to a text file.  I created the below script that reboots the machine and creates the output file, but when I open the file I do not see any results in it. 

restart-computer (get-content c:\reboot\rebootlist.txt) | out-file -filepath c:\results.txt

I also found the below script but for some reason it will not work, but it's not rebooting the machines.  I can get it to show me the list of machines in the text file but it does not reboot them.  My plan was to get it working and output the results to a file, but it's not working out for me.

Get-Content C:\reboot\rebootlist.txt |
   Where {test-connection $_ -quiet -count 2} |
   foreach {
    write-host "Restarting $_ "-force "Green"
    Restart-Computer $_ -force -whatif}

Please let me know if you have any suggestions.

 


Viewing all articles
Browse latest Browse all 8583

Trending Articles