none
turn off computers with a script RRS feed

  • Question

  • when I try to shut down multiple computers and attempt to load the ip of the computers in a txt it does not work. I tried two ways and fails. I need to turn off 40 pcs, it is difficult to write all these ips.

    first form

    (get-wmiobject -class win32_operatingsystem -computername (invoke-command { get-content C:\Users\Eventos\Documents\ip.txt } -computername \\N00019396)).win32shutdown(6)

    second form

    (get-wmiobject -class win32_operatingsystem -computername (Get-Content \\N00019396\Users\Eventos\Documents\ip.txt)).win32shutdown(6)

    Thursday, June 16, 2016 10:11 PM

Answers

  • Bad syntax:

    Get-content C:\Users\Eventos\Documents\ip.txt |
    ForEach-Object{
    	$c = get-wmiobject -class win32_operatingsystem -computername $_
    	$c.win32shutdown(6)
    }
    

    OR

    Get-content C:\Users\Eventos\Documents\ip.txt |
    ForEach-Object{
    	shutdown /f /s /m "\\$_"
    }
    


    \_(ツ)_/

    Thursday, June 16, 2016 10:50 PM