This project is read-only.


This module allows managing local groups and user accounts, local group memberhip and some other useful tasks. It is mostly based on the .net classes in System.DirectoryServices.AccountManagement and some classes written in C#. The source code is also available.

All cmdlets suport the pipeline so that also complex tasks are very easy to do. Some samples are below.

All cmdlets are documented with examples.

Release Notes

Version 2.1 now supports connecting to other machines or domains using alternate credentials. Use the parameter 'Credential' for this.

Version 2.0 is no longer a script but a binary module. This should increase performance and made the development much easier.

Some new cmdlets have been added but in general it behaves pretty much like version 1.01.


Just create the folder "LocalAccounts" in one of the standard module folders and copy the files attached in there. The standard module folders are in the environment variable %PSModulePath%, for example C:\Users\<username>\Documents\WindowsPowerShell\Modules.

For example, all the files in the zip file have to be in "C:\Users\raandree\Documents\WindowsPowerShell\Modules\LocalAccounts". If you did this then the module should be listed in "Get-Module -ListAvailable" and can be imported using "Import-Module LocalAccounts".
LocalAccount 1.0 C# Solution: LocalAccount
Security2 1.2 C# Solution: Security2


The module is based on .net Framework 3.5. 


The module provides the following script cmdlets:

  • Add-LocalGroupMember
  • Disable-LocalUser
  • Enable-LocalUser
  • Get-LocalAccountPolicy
  • Get-LocalGroup
  • Get-LocalGroupMember
  • Get-LocalUser
  • New-LocalGroup
  • New-LocalUser
  • Remove-LocalGroup
  • Remove-LocalGroupMember
  • Remove-LocalUser
  • Rename-LocalGroup
  • Rename-LocalUser
  • Set-LocalGroup
  • Set-LocalUser
  • Set-LocalUserPassword
  • Unlock-LocalUser

Example 1

 The following script creates a teset group and 10 test users. All 10 test users are added to the group.

$testUsers = 1..10 | ForEach-Object { New-LocalUser -Name ("Test_{0:00}" -f $_) -Password ("Test_{0:00}" -f $_) -Description Testing } 
$testGroup = New-LocalGroup -Name TestGroup1 -Description Testing -PassThru 
$testGroup | Add-LocalGroupMember -Members $testUsers

 Example 2

This one-liner gets all groups from the local machine and read the group membership of all groups.
Get-LocalGroup -All | ForEach-Object { $_ | Get-LocalGroupMember | Add-Member -Name Group -MemberType NoteProperty -Value $_ -PassThru } | Format-Table Group,Name,FullName,SID -AutoSize



  • Initial Release


  • Fixed: Get-LocalGroupMembership does not work when there are unresolvable SIDs in the membership list

LocalAccounts 2.0 / LocalAccounts 2.0

  • Build from scratch now in C# as a binary module.

LocalAccounts 2.1 / LocalAccounts 2.1

  • Supports connecting to other machines or domains using alternate credentials 

Last edited Mar 16, 2013 at 10:51 PM by raandree, version 3