Jump to content


  • 0
J03

Currently logged in users

Question

Hi All,

 

Can someone help me with a script (Powershell or VB) to populate the currently logged in username from Computers ?

 

What I have ?

 

A spreadsheet with Computer names.

 

Eg:

COMP001

COMP002

.

.

.

COMP00n

 

What I am looking for ?

 

A script that reads Computer names from the spreadsheet and finds the currently logged in users on these computer and export the details to another spreadsheet in a something similar format.

 

COMP001 Adam

COMP002 Brian

 

I tried some scripts which I got from different forums out there but I am not getting what I am trying to achieve.

 

Thanks,

Joe

Share this post


Link to post
Share on other sites

3 answers to this question

Recommended Posts

  • 0

I have used:

$ComputerlistPath = 'c:\temp\computerlist.txt'
$ComputerList = Get-Content -Path $ComputerlistPath; # one computer a line
foreach ($computer in $computerList){
    ($computer + ": " + @(Get-WmiObject -ComputerName $computer -Namespace root\cimv2 -Class Win32_ComputerSystem)[0].UserName);
}

To get this information a few times. you can probably use this as a basis to make a script do what you want.

Share this post


Link to post
Share on other sites

  • 0

Thanks a ton...

 

I've tried this on my local machine and it works perfectly. I just need to redirect the result to an excel file which is not a big deal

 

However, I still need to give it a try inside my office network and see how it works.

 

Will come back with the updates.

 

Thanks again.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...


×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.