![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | finding the logged on user (user name) with powershell using WMI? whats a good way of finding out the currently logged in user of a particular machine? i do get-WmiObject -computer . Win32_LoggedOnUser but it returns alot of rows, including network services, users for my VMWARE, etc etc plus it seems i'd have to parse the actual user name out of a string looking like this Win32_LoggedOnUser.Antecedent="\\\\.\\root\\cimv2:Win32_Account.Domain=\"DCLSW2B1\",Name=\"ANONYMOUS LOGON\"",Dependent="\\\\.\\root\\cimv2:Win32_LogonSession.LogonId=\"84152\"" or parse it out of the get properties value Name : Antecedent Value : \\.\root\cimv2:Win32_Account.Domain="DCLSW2B1",Name="NETWORK SERVICE" Type : Reference IsLocal : True IsArray : False Origin : CIM_Dependency Qualifiers : {CIMTYPE, key} Name : Dependent Value : \\.\root\cimv2:Win32_LogonSession.LogonId="996" Type : Reference IsLocal : True IsArray : False Origin : CIM_Dependency Qualifiers : {CIMTYPE, key} Name : Antecedent Value : \\.\root\cimv2:Win32_Account.Domain="DCLSW2B1",Name="__vmware_user__" Type : Reference IsLocal : True IsArray : False Origin : CIM_Dependency Qualifiers : {CIMTYPE, key} Name : Dependent Value : \\.\root\cimv2:Win32_LogonSession.LogonId="97553" Type : Reference IsLocal : True IsArray : False Origin : CIM_Dependency Qualifiers : {CIMTYPE, key} Name : Antecedent Value : \\.\root\cimv2:Win32_Account.Domain="KARLDOMAIN",Name="kprosser" Type : Reference IsLocal : True IsArray : False Origin : CIM_Dependency Qualifiers : {CIMTYPE, key} Name : Dependent Value : \\.\root\cimv2:Win32_LogonSession.LogonId="133927" Type : Reference IsLocal : True IsArray : False Origin : CIM_Dependency Qualifiers : {CIMTYPE, key} if i have to , its not a biggie to write an expression to parse the name out of the value, but also i am wanting to user who is logged into the desktop, and i have no way to distinquish between kprosser and the others (other than ignoring some common ones) Help anybody? Karl |
My System Specs![]() |
| | #2 (permalink) |
| | Re: finding the logged on user (user name) with powershell using WMI? Karl, As I understand the login subsystem, and anyone please correct me if I am wrong, there is no one "logged in" or "desktop" user. Specifically, all interactive users are provided one or more desktops with which to interact. Additionally, there is no way to guarantee that any given console session is actually running through the physically connected input and output devices. The console session dedicated to the physically attached console, session 0, is used by RDP connections to Windows XP systems or Windows Server 2003 systems when specifically requested. On server systems, additional console sessions are allocated when session 0 is not explicitly requested. On a related note, console sessions that are not actively logged in by a user also have desktops for the purposes of providing login mechanisms. Is there something more specific that you are trying to achieve? - Alex B Chalmers <klumsy@xtra.co.nz> wrote in message news:1158880817.192591.42750@i3g2000cwc.googlegroups.com... > whats a good way of finding out the currently logged in user of a > particular machine? > > i do > > get-WmiObject -computer . Win32_LoggedOnUser > > but it returns alot of rows, including network services, users for my > VMWARE, etc etc > > plus it seems i'd have to parse the actual user name out of a string > looking like this > > Win32_LoggedOnUser.Antecedent="\\\\.\\root\\cimv2:Win32_Account.Domain=\"DCLSW2B1\",Name=\"ANONYMOUS > > LOGON\"",Dependent="\\\\.\\root\\cimv2:Win32_LogonSession.LogonId=\"84152\"" > > or > > parse it out of the get properties value > > Name : Antecedent > Value : > \\.\root\cimv2:Win32_Account.Domain="DCLSW2B1",Name="NETWORK SERVICE" > Type : Reference > IsLocal : True > IsArray : False > Origin : CIM_Dependency > Qualifiers : {CIMTYPE, key} > Name : Dependent > Value : \\.\root\cimv2:Win32_LogonSession.LogonId="996" > Type : Reference > IsLocal : True > IsArray : False > Origin : CIM_Dependency > Qualifiers : {CIMTYPE, key} > > > Name : Antecedent > Value : > \\.\root\cimv2:Win32_Account.Domain="DCLSW2B1",Name="__vmware_user__" > Type : Reference > IsLocal : True > IsArray : False > Origin : CIM_Dependency > Qualifiers : {CIMTYPE, key} > Name : Dependent > Value : \\.\root\cimv2:Win32_LogonSession.LogonId="97553" > Type : Reference > IsLocal : True > IsArray : False > Origin : CIM_Dependency > Qualifiers : {CIMTYPE, key} > > > Name : Antecedent > Value : > \\.\root\cimv2:Win32_Account.Domain="KARLDOMAIN",Name="kprosser" > Type : Reference > IsLocal : True > IsArray : False > Origin : CIM_Dependency > Qualifiers : {CIMTYPE, key} > Name : Dependent > Value : \\.\root\cimv2:Win32_LogonSession.LogonId="133927" > Type : Reference > IsLocal : True > IsArray : False > Origin : CIM_Dependency > Qualifiers : {CIMTYPE, key} > > > > if i have to , its not a biggie to write an expression to parse the > name out of the value, but also i am wanting to user who is logged into > the desktop, and i have no way to distinquish between kprosser and the > others (other than ignoring some common ones) > > Help anybody? > Karl > |
My System Specs![]() |
| | #3 (permalink) |
| | RE: finding the logged on user (user name) with powershell using WMI? (gwmi -class win32_computerSystem).username will show the user currently logged onto the machine. Doesnt retrun results as far as I know for "guest" users on the machine. -Jake "klumsy@xtra.co.nz" wrote: > whats a good way of finding out the currently logged in user of a > particular machine? > > i do > > get-WmiObject -computer . Win32_LoggedOnUser > > but it returns alot of rows, including network services, users for my > VMWARE, etc etc > > plus it seems i'd have to parse the actual user name out of a string > looking like this > > Win32_LoggedOnUser.Antecedent="\\\\.\\root\\cimv2:Win32_Account.Domain=\"DCLSW2B1\",Name=\"ANONYMOUS > > LOGON\"",Dependent="\\\\.\\root\\cimv2:Win32_LogonSession.LogonId=\"84152\"" > > or > > parse it out of the get properties value > > Name : Antecedent > Value : > \\.\root\cimv2:Win32_Account.Domain="DCLSW2B1",Name="NETWORK SERVICE" > Type : Reference > IsLocal : True > IsArray : False > Origin : CIM_Dependency > Qualifiers : {CIMTYPE, key} > Name : Dependent > Value : \\.\root\cimv2:Win32_LogonSession.LogonId="996" > Type : Reference > IsLocal : True > IsArray : False > Origin : CIM_Dependency > Qualifiers : {CIMTYPE, key} > > > Name : Antecedent > Value : > \\.\root\cimv2:Win32_Account.Domain="DCLSW2B1",Name="__vmware_user__" > Type : Reference > IsLocal : True > IsArray : False > Origin : CIM_Dependency > Qualifiers : {CIMTYPE, key} > Name : Dependent > Value : \\.\root\cimv2:Win32_LogonSession.LogonId="97553" > Type : Reference > IsLocal : True > IsArray : False > Origin : CIM_Dependency > Qualifiers : {CIMTYPE, key} > > > Name : Antecedent > Value : > \\.\root\cimv2:Win32_Account.Domain="KARLDOMAIN",Name="kprosser" > Type : Reference > IsLocal : True > IsArray : False > Origin : CIM_Dependency > Qualifiers : {CIMTYPE, key} > Name : Dependent > Value : \\.\root\cimv2:Win32_LogonSession.LogonId="133927" > Type : Reference > IsLocal : True > IsArray : False > Origin : CIM_Dependency > Qualifiers : {CIMTYPE, key} > > > > if i have to , its not a biggie to write an expression to parse the > name out of the value, but also i am wanting to user who is logged into > the desktop, and i have no way to distinquish between kprosser and the > others (other than ignoring some common ones) > > Help anybody? > Karl > > |
My System Specs![]() |
| | #4 (permalink) |
| | Re: finding the logged on user (user name) with powershell using WMI? Alex is right. That said, your PowerShell session runs under a particular security context, so if what you are trying to achieve is to get the corresponding account you can use this: [System.Security.Principal.WindowsIdentity]::GetCurrent() Jacques "Alex B Chalmers" <alex@alexbchalmers.com> a écrit dans le message de news: 1AF402DD-CEBD-4DA6-8946-FF4B56484EC6@microsoft.com... > Karl, > > As I understand the login subsystem, and anyone please correct me if I am > wrong, there is no one "logged in" or "desktop" user. Specifically, all > interactive users are provided one or more desktops with which to > interact. Additionally, there is no way to guarantee that any given > console session is actually running through the physically connected input > and output devices. The console session dedicated to the physically > attached console, session 0, is used by RDP connections to Windows XP > systems or Windows Server 2003 systems when specifically requested. On > server systems, additional console sessions are allocated when session 0 > is not explicitly requested. On a related note, console sessions that are > not actively logged in by a user also have desktops for the purposes of > providing login mechanisms. > > Is there something more specific that you are trying to achieve? > > - Alex B Chalmers > > > <klumsy@xtra.co.nz> wrote in message > news:1158880817.192591.42750@i3g2000cwc.googlegroups.com... >> whats a good way of finding out the currently logged in user of a >> particular machine? >> >> i do >> >> get-WmiObject -computer . Win32_LoggedOnUser >> >> but it returns alot of rows, including network services, users for my >> VMWARE, etc etc >> >> plus it seems i'd have to parse the actual user name out of a string >> looking like this >> >> Win32_LoggedOnUser.Antecedent="\\\\.\\root\\cimv2:Win32_Account.Domain=\"DCLSW2B1\",Name=\"ANONYMOUS >> >> LOGON\"",Dependent="\\\\.\\root\\cimv2:Win32_LogonSession.LogonId=\"84152\"" >> >> or >> >> parse it out of the get properties value >> >> Name : Antecedent >> Value : >> \\.\root\cimv2:Win32_Account.Domain="DCLSW2B1",Name="NETWORK SERVICE" >> Type : Reference >> IsLocal : True >> IsArray : False >> Origin : CIM_Dependency >> Qualifiers : {CIMTYPE, key} >> Name : Dependent >> Value : \\.\root\cimv2:Win32_LogonSession.LogonId="996" >> Type : Reference >> IsLocal : True >> IsArray : False >> Origin : CIM_Dependency >> Qualifiers : {CIMTYPE, key} >> >> >> Name : Antecedent >> Value : >> \\.\root\cimv2:Win32_Account.Domain="DCLSW2B1",Name="__vmware_user__" >> Type : Reference >> IsLocal : True >> IsArray : False >> Origin : CIM_Dependency >> Qualifiers : {CIMTYPE, key} >> Name : Dependent >> Value : \\.\root\cimv2:Win32_LogonSession.LogonId="97553" >> Type : Reference >> IsLocal : True >> IsArray : False >> Origin : CIM_Dependency >> Qualifiers : {CIMTYPE, key} >> >> >> Name : Antecedent >> Value : >> \\.\root\cimv2:Win32_Account.Domain="KARLDOMAIN",Name="kprosser" >> Type : Reference >> IsLocal : True >> IsArray : False >> Origin : CIM_Dependency >> Qualifiers : {CIMTYPE, key} >> Name : Dependent >> Value : \\.\root\cimv2:Win32_LogonSession.LogonId="133927" >> Type : Reference >> IsLocal : True >> IsArray : False >> Origin : CIM_Dependency >> Qualifiers : {CIMTYPE, key} >> >> >> >> if i have to , its not a biggie to write an expression to parse the >> name out of the value, but also i am wanting to user who is logged into >> the desktop, and i have no way to distinquish between kprosser and the >> others (other than ignoring some common ones) >> >> Help anybody? >> Karl >> > |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Script to find all user and what PC they are logged into | VB Script | |||
| Re: Cannot use ie7 when logged on as a standard user?? | Vista security | |||
| how to get logged-in user credentials? | PowerShell | |||
| User Profile Bad if this user is not first user logged onto Vista | Vista account administration | |||
| Remember last user logged on | Vista account administration | |||