June 18th, 2015

PowerTip: Use PowerShell Grid View to Display Logon Info

Doctor Scripto
Scripter

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.

Author

The "Scripting Guys" is a historical title passed from scripter to scripter. The current revision has morphed into our good friend Doctor Scripto who has been with us since the very beginning.

0 comments

Discussion are closed.

Feedback