How to save CurrentUser as String

Welcome Forums General PowerShell Q&A How to save CurrentUser as String

This topic contains 0 replies, has 1 voice, and was last updated by  Forums Archives 7 years, 2 months ago.

  • Author
  • #5330

    Points: 0
    Rank: Member

    by the_hutch at 2012-12-07 11:26:19

    When I use the command, "Get-CurrentUser" it outputs the username for the person running the script. The output looks like this:

    AuthenticationType : Kerberos
    ImpersonationLevel : None
    IsAuthenticated : True
    IsGuest : False
    IsSystem : False
    IsAnonymous : False
    Name : domainname\username
    Owner : ——–
    User : ——-
    Groups : ——–
    Token : ——-

    I wanted to assign this entire output to a string. Was trying this:

    [string]$User = Get-CurrentUser

    The value of $User becomes "System.Security.Principal.WindowsIdentity" instead of a string of the output above. Does anyone know how I can save the output from Get-CurrentUser to a string variable?

    by RichardSiddaway at 2012-12-07 11:34:14

    $user = Get-CurrentUser | Out-String

    by the_hutch at 2012-12-07 11:43:42

    Thanks Richard. Appreciate the quick reply.

    by RichardSiddaway at 2012-12-09 02:37:51

    You're very welcome

The topic ‘How to save CurrentUser as String’ is closed to new replies.

denizli escort samsun escort muğla escort ataşehir escort kuşadası escort