Remotely grabbing username

This topic contains 3 replies, has 3 voices, and was last updated by Profile photo of Sam Boutros Sam Boutros 2 years, 4 months ago.

  • Author
    Posts
  • #17296
    Profile photo of Mark DiPofi
    Mark DiPofi
    Participant

    I am using Get-item env:\username and I would only like to grab the value so I can set it to $strname

    PS C:\Users\testuser> Get-Item env:\username

    Name Value
    —- —–
    USERNAME testuser

    Thank you for assistance.

  • #17297
    Profile photo of Mark DiPofi
    Mark DiPofi
    Participant

    I was able to figure it out.
    Thank you

  • #17298
    Profile photo of Dave Wyatt
    Dave Wyatt
    Moderator

    For environment variables, there's a shortcut syntax:

    $env:username
    

    I'm not sure where "Remotely" comes into this question, though.

  • #17320
    Profile photo of Sam Boutros
    Sam Boutros
    Participant
    $strName = (Get-Item -Path Env:\USERNAME).value
    

You must be logged in to reply to this topic.