Ever needed to figure out who is logged on when deploying software to a machine with SCCM?
Maybe you needed to do so… like me… to copy a specific file into that users AppData?
Anyway quick PowerShell script to figure out the currently logged on user of a Machine.
################################################################################ #Author: SCCMOG.COM - Richie Schuster # #Date: 04/03/2017 # #Script Name: Get Logged on User # ################################################################################ #Get logged on User $Loggedon = Get-WmiObject -ComputerName $env:COMPUTERNAME -Class Win32_Computersystem | Select-Object UserName #Split User and Domain $Domain,$User = $Loggedon.Username.split('\',2) Write-Host $Domain Write-Host $User ################################################################################
Thanks for this post. I’ve been looking for a way to add logged in users to local admin group (even though requires user to logout and back in)
No worries, glad it helped!
Cheers,
SCCMOG