Missing Module Microsoft.Powershell.LocalAccounts

I am working on a brand-new Windows 10 (Pro) (build 1809) install. I tried to use some basic scripts, and discovered (via testing and experimentation) that the manifest module Microsoft.PowerShell.LocalAccount is missing from this install

$PSVersionTable.PSversion

Major Minor Build Revision

 5      1    17763    316

Interestingly, I couldn’t find Microsoft.PowerShell.LocalAccounts in the “official” repo (https://www.powershellgallery.com). I did find the module “localuser” which SEEMS to be correct. So… I tried to install the module

install-module -name LocalAccount

resulted in errors. So I tried

install-module -name LocalAccount -AllowClobber

…and then

Import-Module -name LocalAccount

<p class=“s14dydj4-10 kiAEUp”>Success…sort of. Get-Module -ListAvailable shows LocalAccount listed as ModuleType: Script (version 1.6), but it specifically is NOT listed under the ModuleType: Manfest list. And… Get-LocalUSer now works, but doesn’t have the same options as I’m used to (specifically, I can’t enumerate the fields “Enabled” or “SID,” both of which I need for the job I’m doing).</p>
<p class=“s14dydj4-10 kiAEUp”>Oh, and running “Get-Module -ListAvailable” on my other computers returns “ModuleType Manfest” “Name: Microsoft.PowerShell.LocalAccounts”. Here’s a shot of one of my systems where it’s installed “properly:”</p>

PS C:\WINDOWS\system32> Get-Module -ListAvailable -Name Microsoft.Powershell.LocalAccounts
 Directory: C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules 
ModuleType Version Name ExportedCommands 
---------- ------- ---- ---------------- 
Manifest 1.0.0.0 Microsoft.PowerShell.LocalAccounts {Add-LocalGroupMember, Disable-LocalUser, Enable-LocalUser... 

PS C:\WINDOWS\system32> $PSVersionTable.PSVersion 
Major Minor Build Revision 
----- ----- ----- -------- 
  5    1    17134   590

Does anyone have ANY ideas? Obviously, the build and version numbers are different, but I don’t know how to revert the new installation to an older build. I did a bunch of searching (on reverting the build, reinstalling Windows management Framework 5.1, and the missing module error/issue specifically) but didn’t find anything helpful. And the kicker - The Windows 10 Pro install was installed from the same installation media from which my other (properly working) systems were installed.

If you have upgraded to latest version, there is an option to “Go back to Previous Build” in Windows 10.

https://mywindowshub.com/go-back-previous-version-windows-windows-10/

PS: This is not an issue with PowerShell.

Hi Kevin,

Try mounting the 1809 ISO and then running:

[pre]
Mount-WindowsImage -ImagePath D:\sources\install.wim -Path C:\temp\1809 -Index 1 -ReadOnly
Copy-Item -Path C:\temp\Windows\System32\WindowsPowerShell\v1.0\Modules\Microsoft.PowerShell.LocalAccounts\ -Destination C:\Windows\system32\WindowsPowerShell\v1.0\Modules\Microsoft.PowerShell.LocalAccounts\ -Recurse -Force
Import-Module Microsoft.PowerShell.LocalAccounts -Force
Get-Command -Module Microsoft.PowerShell.LocalAccounts
[/pre]

Mounting the install.wim will give you access to copy that module back to the default location.

pwshliquori

Also, the LocalAccount module you installed from the PowerShell Gallery is probably not an official module from Microsoft.

You can check the creator of the module by using:

[pre]
Find-Module -Name LocalAccount |Format-List *
[/pre]

pwshliquori

I’ve removed this add-in module, as it wasn’t an authentic Microsoft module

I tried this; I’m still experiencing the same issue. Specifically, I’m seeing different attributes than I expect to see (and that I see on other systems with the same OS version but, as noted in the original posted, apparently a different PSH version). Examples:
<p class=“s14dydj4-10 kiAEUp”>From known-good (“working”) PSH instance, Windows 10 Pro (1803)</p>

PS C:\WINDOWS\system32> 

$PSVersionTable.PSVersion 

Major Minor Build Revision 
----- ----- ----- -------- 
5     1     17134 590 

PS C:\WINDOWS\system32> Get-LocalUser -name ****** | select * 

AccountExpires : 
Description : 
Enabled : True 
FullName : Fname Lname 
PasswordChangeableDate : 4/10/2018 11:21:01 PM 
PasswordExpires : 
UserMayChangePassword : True 
PasswordRequired : False 
PasswordLastSet : 4/10/2018 11:21:01 PM 
LastLogon : 3/31/2019 1:16:11 AM 
Name : ******
SID : S-1-5-21-**********-*********-*******-1002 
PrincipalSource : Local 
ObjectClass : 


User PS C:\WINDOWS\system32>

From suspect machine, Windows 10 Pro (1809):

PS C:\WINDOWS\system32> $PSVersionTable.PSVersion

Major Minor Build Revision
----- ----- ----- --------
5     1     17763 316

PS C:\Windows\system32> Get-LocalUser -name ****** | select *

Name : ******
Fullname : FName LName
Description : 
AutoUnlockInterval : 900
BadPasswordAttempts : 0
HomeDirDrive : 
HomeDirectory : 
LastLogin : 3/31/2019 12:11:03 PM
LockoutObservationInterval : 900
LoginHours : {255, 255, 255, 255...}
LoginScript : 
MaxBadPasswordsAllowed : 3
MaxPasswordAge : 5184000
MaxStorage : -1
MinPasswordAge : 86400
MinPasswordLength : 14
objectSid : {1, 5, 0, 0...}
Parameters : 
PasswordAge : 89779
PasswordExpired : 0
PasswordHistoryLength : 24
PrimaryGroupID : 513
Profile : 
UserFlags : 513

PS C:\Windows\system32>

 

Ok. I have done some testing to find out what is happening. It looks the the command you ran above is still using the module installed from the PowerShell Gallery. I have replicated your result from the previous post.

[pre]
localaccount\Get-LocalUser -name *****

Name : *****
Fullname :
Description :
AutoUnlockInterval : ####
BadPasswordAttempts : 0
HomeDirDrive :
HomeDirectory :
LastLogin : TimeStamp
LockoutObservationInterval : ####
LoginHours : {255, 255, 255, 255…}
LoginScript :
MaxBadPasswordsAllowed : ****
MaxPasswordAge : ****
MaxStorage : ****
MinPasswordAge : ####
MinPasswordLength : ##
objectSid : {sid}
Parameters :
PasswordAge : ###
PasswordExpired : ****
PasswordHistoryLength : ****
PrimaryGroupID : ****
Profile :
UserFlags : ****
[/pre]

To verify the module has been uninstalled, can you run:

Get-InstalledModule -Name localaccount

And if it is still installed:

Uninstall-Module -Name localaccount -Force

Also, to be sure you are running the correct Cmdlet, please try to run:

[pre]
Microsoft.PowerShell.LocalAccounts\Get-LocalUser -Name ****

AccountExpires :
Description : Description
Enabled : False
FullName :
PasswordChangeableDate :
PasswordExpires :
UserMayChangePassword : True
PasswordRequired : True
PasswordLastSet :
LastLogon :
Name : ****
SID : ****
PrincipalSource : Local
ObjectClass : User
[/pre]

This tells PowerShell to use the LocalAccounts module located in C:\Windows\System32\WindowsPowerShell\v1.0\Modules folder.

pwshliquori