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

FacebookTwitterGoogle+Share

Parody tune–“I’m Scripting Now”

I’ll take the blame on this.  A little person put a voice in my head saying “Hey you should re-write Need You Now from Lady Antebellum”

It appears I forgot until this SAME Nameless troublemaker tapped me on the head and said a while later about me doing another one.

It seems I…. errrr…. forgot to do the FIRST Parody.

So sing it to yourself if you like.   The words actually line up.   Your singing voice has got to be way better than mine…. and you probably look better in a Blond wig than I ever would Winking smile

 

Sung to “Need you Now” by Lady Antebellum

“I’m Scripting Now”

 

Picture all the days
I sat upon a on a Server floor
Clicking at a screen now
Staring longing for the door

How I wish I could have scripted way back when
I’d be home within my den

 

CHORUS

It’s a quarter after one
There’s too much to get done
and I’m Scripting Now
I open PowerShell
On my Little Dell
and I’m Scripting Now
Oh I don’t know how I’d do without
All my Cmdlets now

 

Another long night looming
Pulling off Recovery
Wish they was a way now
to run it and just set me free

How I wish could have scripted way back when
I’d be home within my den

 

CHORUS

It’s a quarter after one
There’s too much to get done
and I’m Scripting Now
I open PowerShell
On my Little Dell
and I’m Scripting Now
Oh I don’t know how I’d do without
All my Cmdlets now

Oh, whoa
Now I get to show you how to script it all!

 

CHORUS

It’s a quarter after one
There’s too much to get done
and I’m Scripting Now
I open PowerShell
On my Little Dell
and I’m Scripting Now
Oh I don’t know how I’d do without
All my Cmdlets now

FacebookTwitterGoogle+Share

Microsoft EMET–Importing Configuration does not alter PINNING settings

Ran into this one today.   Incredibly odd (So I figure chalk this up to a “Bug”)

The normal process to obtain the configuration from the Microsoft Enhanced Mitigation Experience Toolkit is to run this command.

EMET_Conf.exe –export settings.xml

In doing so you will have an XML which contains all of the settings the application needs.  If you were to examine this file you would see the following line which indicates “Pinning is disabled” near the top

image

Then what you need to do on a workstation is to simply run this line to import the settings.

EMET_Conf.exe –import settings.xml

Seems simple right?  It is.  Except that if you were expecting the see the Pinning configuration carry over, well err… no such luck in version 5.1, at least not on a 64 bit version of Windows (I’ll test this on a 32bit version later)

If this is where you are in a pickle just add in this line after you update the settings to force the Pinning feature as off

EMET_Conf.exe –system Pinning=Disabled

Likewise if you were trying to force them to Enabled you can run this line for the opposite desired effect.

EMET_Conf.exe –system Pinning=Enabled

Now the other piece I have noticed is you might need to restart the service for some settings to take effect.   To make this all happen nicely you can use this little script to do the dirty work

EMET_Conf.exe –import settings.xml

EMET_Conf.exe –system Pinning=Disabled

NET STOP Emet_Service

NET START Emet_Service

In Windows PowerShell it would look like this

& ‘EMET_Conf.exe’ –import settings.xml

& ‘EMET_Conf.exe’ –system pinning=enabled

Restart-Service EMET_Service

 

Cheers !
Sean
The Energized Tech

FacebookTwitterGoogle+Share