Solved

List local user account from a CSV file

Posted on 2010-11-17
2
733 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

Suggested Solutions

Title # Comments Views Activity
Exchange 2013 - Get Public Folder Path 2 26
Add a line to move accounts to another OU 2 29
rename files 4 25
How to monitor servers ? 4 23
Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
Synchronize a new Active Directory domain with an existing Office 365 tenant
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

828 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