We manage a few hundred Windows 7 computers in a Windows domain. My IT team is not part of the central IT department so we are not domain admins but are local admins on the computers we manage by virtue of a global group in AD. Fairly often we need to RDP to a user's computer to do maintenance and it would be helpful if we didn't need to coordinate with the user to find a time when they are not logged in. Users log in to the domain on their computers when in their offices but may also connect from home via RDP. I have used the Sysinternals PSLoggedon command but this is a manual process and I'd like to be able to run a batch against a list of computers.
I see that the page below has both Powershell and what appears to be VBscript code but I don't know how to modify these to get the computer names from a text file and send the results to a CSV file.
Ideally I would like the output to go to a CSV file with the status next to each computer name, either "no user logged on" or "[username] local" or [username remote]
Something I have noticed is that even when I go to a machine and log on locally, sometimes when the task I'm doing requires a restart I see "another user is logged on. Do you want to restart?". We deploy Windows 7 Enterprise x-64 and I didn't think it supported user switching. When I came to the computer it didn't say "This computer is in use by [username] and locked". It just said "Press CTRL+ALT+DEL to log on" so I'm a little confused about how to tell if someone is logged in via user switching when looking at the machine locally. Hopefully the script I've described above can reveal this.