I just tried it on a computer I know nobody is currently logged into, and it's reporting the same time - the approximate time since the last reboot of the system. Idle for 0 days, 13 hours, 16 minutes, 13 seconds. Invoke-Command -ComputerName COMPUTERNAME -FilePath \\path\to\scripts\TESTING-IdleTime.ps1īoth the machine I'm running the command on, and the remote computer, are Windows. Start-Sleep -Seconds (Get-Random -Minimum 1 -Maximum 10) Write-Host (" Idle for " $Idle.Days " days, " $Idle.Hours " hours, " $Idle.Minutes " minutes, " $Idle.Seconds " seconds.") Write-Host (" Last user keyboard/mouse input: " $LastStr) $LastStr = $Last.ToLocalTime().ToString("MM/dd/yyyy hh:mm tt") Lii.cbSize = (uint)Marshal.SizeOf(typeof(LASTINPUTINFO)) Private static extern bool GetLastInputInfo(ref LASTINPUTINFO plii) ĭateTime bootTime = (-Environment.TickCount) ĭateTime lastInput = bootTime.AddMilliseconds(LastInputTicks) # c:\admin\pstools\psexec.exe \\COMPUTERNAME powershell.exe -command Enable-PSRemoting 4) Select one item that you don’t need to open at startup and click the Disable button. 2) Type msconfig in the run box and click the OK button. Here's the exact code I'm running - slightly tweaked from the original: # via Can I disable System Idle Process 1) On your keyboard, press Win R (the Windows logo key and the R key) at the same time to invoke the run box. It returns results as I would expect when run locally, but when I try to execute on a remote computer I get strange results: it's telling me idle time of over 13 hours - but I just walked out of this user's office and know the idle time should be in the magnitude of seconds. I'm trying to run code posted in Get idle time of machine.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |