Skip to main content

Posts

Showing posts from April, 2014

2014 North America PowerShell Summit

Well, It was a blast for many reasons.  First and foremost, I delivered my presentation on “Empowering Your Help Desk with PowerShell” to a packed room.  The food was amazing but most importantly, I met some really great people.  I’m looking forward to next year in Charlotte, NC and even possibly the PowerShell Summit in Europe. I’m at the airport now watching my flight delays mount and working on my code.  I hope to get home by 1:30 AM

How to get the Currently Logged on User with PowerShell

In the past, I have used the USERNAME property from Win32_ComputerSystem to recover the currently logged on user on a remote client.  I’ve notice that with Windows 8, this may no longer be possible where executing it against a remote system or in a virtual environment.  I do not know why, but I do know that some of my code is non-functional because of this. While researching this problem, I came across the command quser .  According to Microsoft , quser “Displays information about user sessions on a Remote Desktop Session Host (RD Session Host) server.”  This command will return a few strings of text, or an error if no one is logged in.  One of the commands’ properties, SessionName, will return console if the user is logged in locally.  Below is my code to allow for you to utilize quser and retrieve the information as a PowerShell object.  This code requires that PowerShell’s remoting capability be turned on for any client that you execute it against.   1 2 3 4 5 6 7