[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now


List local user account from a CSV file

Posted on 2010-11-17
Medium Priority
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?

Question by:gcl_hk
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
LVL 71

Accepted Solution

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.



Author Closing Comment

ID: 34229184

Featured Post

Creating Active Directory Users from a Text File

If your organization has a need to mass-create AD user accounts, watch this video to see how its done without the need for scripting or other unnecessary complexities.

Question has a verified solution.

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

A quick Powershell script I wrote to find old program installations and check versions of a specific file across the network.
A walk-through example of how to obtain and apply new DID phone numbers to your cloud PBX enabled users that are configured in Office 365. Whether you have 1, 10 or 100+ users in your tenant, it's quite easy to get them phone-enabled and making/rece…
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…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

649 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