Grab our RSS feeds Follow us on Twitter Join our Facebook Group Connect with us on LinkedIn
myITforum.com, Powered by You.
you are not logged in

Articles

Newslinks

Links

Downloads

Site Services

Community Forums

Discussion Lists

Article Search

Newsletter

Web Blogs

FAQs

Live Support

myITforum TV

Take a Poll

Monthly Drawing

myITforum Network

User Group Directory

Our Partners

About Us

Register

Login

BRONZE PARTNER:

BRONZE PARTNER:



Industry News:




  Home : Articles : Windows PowerShell print | email | | Forums |   print | email | | Blogs |   print | email | | Wiki |   print | email | | FAQs |   print | email | Article Search  
PowerShell Script To Get The Logged On User Name For A Specified Machine


Bookmark and Share

By: Don Hite
Posted On: 7/2/2007

This article was Previously posted on Don Hite's Blog

This PowerShell script will take a machine name and return the machine name and the logged on user name for the machine specified.

Be sure to change “.” To the machine that you want to query as in: -Comp RemoteMachineName

PowerShell Script:

$CS = Gwmi Win32_ComputerSystem -Comp "."
"Machine Name: " + $CS.Name
"Logged On User: " + $CS.UserName

This can also be written without using the CS variable as shown below however the formatting to the screen may not be very appealing to most people:

Gwmi Win32_Computersystem -Comp "." | Select Name, UserName


  myITforum.com ©2010 | Legal | Privacy