Skip to main content

Command Palette

Search for a command to run...

Find Users Logged Into Remote Computer

Updated
2 min read
Find Users Logged Into Remote Computer
B

Bradley Schacht is a Principal Program Manager on the Microsoft Fabric product team based in Saint Augustine, FL. Bradley is a former consultant, trainer, and has coauthored 6 SQL Server and Power BI books, most recently Learn Microsoft Fabric. As a member of the Microsoft Fabric product team, Bradley works directly with customers to solve some of their most complex data problems and helps shape the future of Microsoft Fabric. Bradley gives back to the community through speaking at events such as the SQLBits, Fabric Community Conference, PASS Community Data Summit, SQL Saturdays, Code Camps, and user groups across the country including locally at the Jacksonville SQL Server User Group (JSSUG). He is a contributor on SQLServerCentral.com and blogs on his personal site, BradleySchacht.com.

Have you ever wanted to find out if someone is logged into a computer or maybe who is logged into a computer without having to remote in to check? Recently I was working on a project doing some SharePoint work using 3 accounts: Admin/Install, Farm and Service. The work I was doing required a lot of remote desktop switching between those three accounts, across three environments, plus the SQL Servers and SQL Server service account. Rather than opening up Remote Desktop and logging into each server to see what accounts were logged in I figured I would fire up the good ol' command line and check that way. There are tons of other ways to do this using PowerShell and I'm sure other command line methods, but this one is quick and easy. Just fire up the command prompt or PowerShell and run this: query session /server:"" query session /server:"KERBEROS-SP" As we see in the screenshot there is one user logged into this computer, the Administrator account. If you want to check multiple computers just create a list in notepad and save it as a batch file to run. This clearly won't work for a large quantity of servers, but it worked great for the 6 servers I needed to check. Unfortunately if the user does not have the appropriate permissions on the server they will not get an error message. Instead the result will list no sessions.

More from this blog

B

Bradley Schacht

180 posts

Bradley Schacht is a Principal Program Manager on the Microsoft Fabric product team based in Saint Augustine, FL.