PowerTip: Use a .NET Framework Class in PowerShell to Get User Info

Summary: Use a .NET Framework class in Windows PowerShell to get user name and domain name information.

Hey, Scripting Guy! Question How can I use a .NET Framework class in Windows PowerShell to get a user name and domain in the format userdomain\username, without building a string?

Hey, Scripting Guy! Answer Use the Name property from the GetCurrent static method of the WindowsIdentity .NET Framework class:


Comments (5)

  1. Anonymous says:

    This is actually a pretty nice tip!

    How do one come to know all(or the cool ones) the features of the dotNet framework classes?

  2. jrv says:

    Here is the explanation for the Microsoft implementation of the access ‘token’ for the users current process context:


  3. jrv says:

    @ mockmyb

    There are manyu kinds of tokens.  There are token gifts and token players as well as subway and bus tokens.

    IBM has invented a computer token.  Her eis the explanation for it:  pic.dhe.ibm.com/…/index.jsp

  4. mockmyberet says:

    Great tip. Explain why the .token changes.

Skip to main content