![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | checked for logged on user on remote machine + remote reboot i want to write something like the following... foreach ($computer in $list) { if (!(any-user-logged-in-to-$computer)) { reboot $computer } } so...there should be some WMI to retrieve that says if any user is logged in or not... help =D |
My System Specs![]() |
| | #2 (permalink) |
| | Re: checked for logged on user on remote machine + remote reboot That would be something like: $computers ="server1","server2","server3" gwmi win32_computersystem -computer $computers | where {$_.username} | foreach { (gwmi Win32_OperatingSystem -computer $_.__server).reboot() } ----- Shay Levi $cript Fanatic http://scriptolog.blogspot.com Quote: > i want to write something like the following... > > foreach ($computer in $list) { > if (!(any-user-logged-in-to-$computer)) { reboot $computer } > } > so...there should be some WMI to retrieve that says if any user is > logged in or not... > > help =D > |
My System Specs![]() |
| | #3 (permalink) |
| | Re: checked for logged on user on remote machine + remote reboot thanks! here's the final script ![]() $list = get-content c:\ps-testing\machines.txt $output = "c:\ps-testing\youroutputfile.csv" if (test-path $output) { remove-item $output } add-content $output "Rebooted, Unreachable, Logged in User" foreach ($machine in $list) { if (test-path "\\$machine\c$\") { if (gwmi win32_computersystem -computer $machine | where {(!($_.username))}) { gwmi win32_computersystem -computer $machine | foreach { (gwmi win32_operatingsystem -computer $_.__Server).reboot() add-content $output "$machine,-,-" } } else { add-content $output "-,-,$machine" } } else { add-content $output "-,$machine,-" } } "Shay Levi" wrote: Quote: > > > That would be something like: > > > $computers ="server1","server2","server3" > gwmi win32_computersystem -computer $computers | where {$_.username} | foreach > { (gwmi Win32_OperatingSystem -computer $_.__server).reboot() } > > > > ----- > Shay Levi > $cript Fanatic > http://scriptolog.blogspot.com > Quote: > > i want to write something like the following... > > > > foreach ($computer in $list) { > > if (!(any-user-logged-in-to-$computer)) { reboot $computer } > > } > > so...there should be some WMI to retrieve that says if any user is > > logged in or not... > > > > help =D > > > > |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| How to view remote certificates installed on remote machine? | PowerShell | |||
| See who is logged in on a remote computer. | PowerShell | |||
| Remote Desktop Crashes Vista machin logged into | Vista General | |||
| Reboot via Remote Desktop? | Vista General | |||
| Remote Desktop - Able to have one user logged in locally and one user via remote desktop? | Vista networking & sharing | |||