Oneliner: Get Logged on Users with Powershell

Check out this oneliner/function! Provide a computer name and it will return the logged on users.

function Get-MyLoggedOnUsers
 Get-WmiObject Win32_LoggedOnUser -ComputerName $Computer | Select Antecedent -Unique | %{“{0}{1}” -f $_.Antecedent.ToString().Split(‘”‘)[1], $_.Antecedent.ToString().Split(‘”‘)[3]}


Rosalind Cardinal is The Leadership Alchemist and Principal Consultant of Shaping Change, an Australian consultancy specializing in improving business outcomes by developing individuals, teams and organizations. To wash down the pub grub, put back a pint or a flight of house brews like the Wild Oyster Stout with a hint of briny bivalves or the crisp tart Lemongrass Wheat Ale that won a medal at the World Beer Cup. “The law is not meant for the state to interfere in that precious relationship of a parent and a child unless the disciplining of that child crosses that line. “Concussion” is the story of Nigerian born pathologist, Bennet Omalu. I actually like to wholesale nfl jerseys leave my epoxy that’s left over on this pad. In 1998 when Jason Elam kicked a 63 yard field goal against the Jaguars to tie Tom Dempsey game winning record set in 1970, I was convinced that that distance was the human limit for kicking a field goal. Then, in her cheap oakleys late 20s, her parents Cheap Football Jerseys were both killed in Authentic Jerseys Sale a car accident. In sports, the return to Thursday night football will give us a tremendous promotional platform to launch our new fall lineup. It puts fear in your heart and makes you wonder what the heck you’re doing playing football.”. Gamblin Matt and the Odds plus Winner: Panthers are $1.70 to win this series while the Islanders are $2.21. But while it existed, depictions of its seeds were widespread across the Roman Empire, to the point where it appeared on their money. “I have concerns you know when we think back over Cheap NFL Jerseys the last 100 years and the horrible wars, the Wholesale Jerseys kind of blood that was shed throughout Europe the idea of the countries coming closer together is something that we want to see.”. Barton Corbin, a tall, handsome dentist, who was 40. Argentina have arrived in New Zealand for their test against the All Blacks in Hamilton next Saturday, and the match up is a fascinating one for me.Are we going to see a side who can push the All Blacks really put them under pressure? Because we didn’t see that in the two tests against Australia.Certainly in the Wales series this new young group of men had to find a way to win under pressure. And Borders doesn’t just recommend this for newbie families, but also moms who may have tried breastfeeding before and found it difficult.. Whether you play tackle or defensive end, the ability to react quickly is essential for effective defensive line play. You need enough speed to get to the second level of the defense and block would be tacklers beyond the line of scrimmage. They can only forage while in the blazing heat and they can only survive for a few moments before they fry, so they have to get out, find the food.

9 thoughts on “Oneliner: Get Logged on Users with Powershell”

  1. Hugo,

    your script is almost working 🙂

    can only give me the following result:

    Laptop425LOCAL SERVICE

    how to get MYDOMAINusername only ?

  2. I’ve just made a little change in the script to add the computername.
    You can now use it with a server list as well as a single server.

    function Get-MyLoggedOnUsers
    Get-WmiObject Win32_LoggedOnUser -ComputerName $Computer |
    Select __SERVER, Antecedent -Unique |
    %{"{0} : {1}\{2}" -f $_.__SERVER, $_.Antecedent.ToString().Split('"')[1], $_.Antecedent.ToString().Split('"')[3]}

    Get-MyLoggedOnUsers localhost


    Get-MyLoggedOnUsers Server1


    $Server_List = ("Server1","Server2","Server3")
    Get-MyLoggedOnUsers $Server_List

  3. Yours, combined with

    function get-loggedonusers
    $computers = get-wmiobject Win32_Computersystem -computername $Computer
    $report = @()
    foreach ($c in $computers) {
    $temp = "" | Select Computer, Username
    $temp.Computer = $
    $temp.Username = $c.username
    $report += $temp

    Dump anything else from in there if needed.

    Thanks for your method.

  4. To output the current username by itself, use:

    function Get-LoggedOnUsers {
    $Computers = HOSTNAME
    $Computers | foreach {$((Get-WmiObject Win32_ComputerSystem | Select UserName | Format-Table -HideTableHeaders | Out-String) -split ‘\\’)[1]}


    To output the username as DOMAIN\username, use:

    function Get-LoggedOnUsers {
    $Computers = HOSTNAME
    $Computers | foreach {$(Get-WmiObject Win32_ComputerSystem | Select UserName | Format-Table -HideTableHeaders | Out-String)}


    Hope this helps

  5. I run this locally and I get the user just fine. But if I put in a remote computer, I just get a blank. Are there any security settings to be aware of while running this? I run the script as an Admin of the remote computers as well.

Leave a Reply