Microsoft Reduce Customer Effort Center

Our team drives product feedback based on solid data, it drives proactive issue prevention and ultimately, drives improvements around products based on customer feedback.

How to determine if current user is a domain or local user?

How to determine if current user is a domain or local user?

  • Comments 3
  • Likes

Assuming you need it in script, PowerShell:

 

(gwmiWin32_LogonSession).GetRelated("Win32_UserAccount")

 

If you expect more than one logon session, then

 

(gwmi Win32_Process -filter "Handle = $Pid").GetRelated("Win32_LogonSession") |% {$_.GetRelated("Win32_UserAccount")}

 

will give you Win32_UserAccount for the account used to run current powershell instance.

Comments
  • When i try (gwmi Win32_LogonSession).GetRelated("Win32_UserAccount"), I get an error

    Method invocation failed because [System.Object[]] doesn't contain a method named 'GetRelated'.

  • Hi Srikanth,

    it's powershell script, the script works perfect:

    1. click start -> type "powershell" in search box

    2. copy and paste the script in the powershell window and press enter.

  • microsoft has a page for me and i can not get passed it to get to my inbox or junk mail please help me to get this problem solved. my phone is217-826-2128

Your comment has been posted.   Close
Thank you, your comment requires moderation so it may take a while to appear.   Close
Leave a Comment