?
Solved

List local user account from a CSV file

Posted on 2010-11-17
2
Medium Priority
?
738 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 71

Accepted Solution

by:
Chris Dent earned 2000 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

A brief introduction to what I consider to be the best editor for PowerShell.
In the absence of a fully-fledged GPO Management product like AGPM, the script in this article will provide you with a simple way to watch the domain (or a select OU) for GPOs changes and automatically take backups when policies are added, removed o…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

752 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