PowerShell Module–Managing Local Users and Groups


I was playing about the other afternoon and quickly put together a module on the Technet Script Repository to allow you to manage users and Groups with Windows Powershell.   There’s another good one out there written by Ed “Hey Scripting Guy” Wilson which I ironically found out AFTER I wrote mine.  

If you’re curious and would like to manage Users and Groups locally and remotely in Windows Powershell you can download it here. If  you have Windows 10 or PowerShell 5 in CTP you can run the following Cmdlet to get the Module and use it right away!

FIND-Module localaccount | INSTALL-Module

You may get prompted to download and install some software which is just part of the components needed to access the Repository with the PowerShell modules.

If you download the module from Technet you can extract the contents to your personal PowerShell modules folder located typically under %UserProfile%\Documents\WindowsPowerShell\Modules\

Once extracted you should be able to just run the following Cmdlet to load up the module

IMPORT-Module localaccount

Once imported you will have a series of new and hopefully self explanatory Cmdlets.  These are also being continually improved so if you see something that isn’t “quite right” or you need something added to it just poke it into the Comments, ping me at @energizedtech or email sean at powershell dot ca so I can add and improve to it.

The current Cmdlets available are

Add-LocalGroupMember
Disable-LocalUser
Enable-LocalUser
Get-LocalGroup
Get-LocalGroupMember
Get-LocalUser
New-LocalGroup
New-LocalUser
Remove-LocalGroup
Remove-LocalGroupMember
Remove-LocalUser
Rename-LocalGroup
Rename-LocalUser

 

I’m working with some code from another MVP, Francois-Xavier Cat to enumerate Group membership.

From this early 1.1 you can see some obvious flaws.  Error messages are defaulting to the standard [ADSI] errors, Help needs to be expanded and I need to get piping working.   But I think to myself “it’s a Start”

So take a look if you like.  The module should work in as low as Powershell 2.0.  As long as you can manage systems via WMI remotely, you should be able to manage older servers with this module.   In theory, you should even be able to manage a Windows 2000 or NT4 box remotely with this (But why do you have one of those in Production?)

So if you missed it here’s the link on Technet to Manage Local Users and Groups with PowerShell or in Windows 10 / PowerShell 5 CTP execute FIND-Module localaccount | INSTALL-Module

Cheers!

Sean
The Energized Tech

Follow

Get every new post delivered to your Inbox.

Join 3,292 other followers