Solved

List local user account from a CSV file

Posted on 2010-11-17
2
728 Views
Last Modified: 2012-05-10
Can any experts can help me plsssss

I have the attached CSV format computer list, is it possible to list out the local user account from the list and output the user account list to another CSV file?

Thanks
Book1.csv
0
Comment
Question by:gcl_hk
2 Comments
 
LVL 70

Accepted Solution

by:
Chris Dent earned 500 total points
ID: 34163073
Hello there,

You can do it like this:
Get-Content book1.csv | ForEach-Object {

  $Computer = $_

  ([ADSI]"WinNT://$Computer").PsBase.Children | 
    Where-Object { $_.Class -eq "User" } |
    Select-Object `
      @{n='ComputerName';e={ $Computer }},
      @{n='Name';e={ $_.Name[0] }}, 
      @{n='Disabled';e={ If ($_.UserFlags[0] -BAnd 2) { $True } else { $False } }}

} | Export-Csv Output.csv -NoTypeInformation

Open in new window

This snippet exports the account name and whether or not the account is disabled.

HTH

Chris
0
 
LVL 6

Author Closing Comment

by:gcl_hk
ID: 34229184
thanks
0

Featured Post

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Utilizing an array to gracefully append to a list of EmailAddresses
Set OWA language and time zone in Exchange for individuals, all users or per database.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

930 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now