PowerTip: Use PowerShell Grid View to Display Logon Info


Summary: Learn how to display user logon information.

Hey, Scripting Guy! Question How can I use Windows PowerShell to display user logon information in an easy graphical manner?

Hey, Scripting Guy! Answer Create two hash tables using environmental variables, and pipe the input to the Out-Gridview cmdlet,
           for example:

@{"username" = $env:USERNAME}, @{"Computername"=$env:COMPUTERNAME} |
Out-GridView -Title "user logon info"

Note This is a single-line command broken at the pipeline character for display on the blog.

Comments (1)

  1. tommymaynard says:

    I’m not sure I’ve seen a hash table piped directly to Out-GridView; very nice. I tested it, and you can also use a single hash table, with two key-pair values: @{‘Username’ = $env:USERNAME; ‘Computername’ = $env:COMPUTERNAME} | Out-GridView

Skip to main content