Wednesday, July 14, 2010

Last Logged-On User / DefaultUserName – PowerShell Script

This script generates Last Logged-On User / DefaultUserName information from an input file (input.csv) which contains computer names.

image

Input file (input.csv) contains all computer names.  “ComputerName” header is a requirement. 

image

Output file

UserInfo.csv – contains computer names and corresponding SamAccountNames

image

FailedCompuers.csv – Script verifies admin$ access. If the access fails, it will be added to the FailedComptuers.csv file.

This script also displays the output on the screen.

image

You can download the script from the following location:

Last Logged-On User.PS1

8 comments:

This is not generating a list of failed computers.

Something wrong with your input file or the script. Post the input file and script here.

can you post a sample input file...i have tried many times with no success and I am sure the error is with the input file

This is how the input file should look like;
(the very first line should be ComputerName)

ComputerName
PCName1
PCName2
PCName3

justin,
Sorry. Somehow I missed your comment. I have updated the blog with a sample input file.

Karloz GtR,
Thanks for providing information. Please let me know if you are interested in becoming a moderator in the SS Technology forum - http://www.sivarajan.com/forum/

It works perfectly for WindowsXP computers... but if fails for Windows 7... any idea?

What is the error message? Please post the error message here.

Karloz GtR,

I can verify that Windows 7 & Windows 2008 Server R2 have changed the path to the data to be:

[Subkey Path]
SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\LogonUI

[Value Name]
LastLoggedOnUser

Post a Comment

Popular Posts

Share

Twitter Delicious Facebook Digg Stumbleupon Favorites More