Share via


Get-LocalUser cmdlet no longer works

Question

Friday, December 16, 2016 7:51 PM

On my raspberrypi2 when I execute Get-LocalUser  it fails as follows:

[192.168.1.107]: PS C:\Data\Users\Administrator\Documents> get-localuser
The 'get-localuser' command was found in the module 'Microsoft.PowerShell.LocalAccounts', but the module could not be loaded. For
more information, run 'Import-Module Microsoft.PowerShell.LocalAccounts'.
    + CategoryInfo          : ObjectNotFound: (get-localuser:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CouldNotAutoloadMatchingModule

Then trying to import the module shows:

[192.168.1.107]: PS C:\Data\Users\Administrator\Documents> Import-Module Microsoft.PowerShell.LocalAccounts -verbose
VERBOSE: Loading module from path
'C:\windows\system32\windowspowershell\v1.0\Modules\Microsoft.PowerShell.LocalAccounts\1.0.0.0\Microsoft.PowerShell.LocalAccounts.psd1'.
VERBOSE: Loading 'FormatsToProcess' from path
'C:\windows\system32\windowspowershell\v1.0\Modules\Microsoft.PowerShell.LocalAccounts\1.0.0.0\LocalAccounts.format.ps1xml'.
VERBOSE: Loading module from path
'C:\windows\system32\windowspowershell\v1.0\Modules\Microsoft.PowerShell.LocalAccounts\1.0.0.0\Microsoft.Powershell.LocalAccounts.dll'.
Could not load file or assembly 'Microsoft.Powershell.LocalAccounts.dll'.  is not a valid Win32 application. (Exception from
HRESULT: 0x800700C1)
    + CategoryInfo          : NotSpecified: (:) [Import-Module], BadImageFormatException
    + FullyQualifiedErrorId : System.BadImageFormatException,Microsoft.PowerShell.Commands.ImportModuleCommand

Id this just my device or are others seeing this as well?

Note this used to work on OS 10.0.14393.321. I know this because I experimented with it after updating the PI following a fresh install.

Below are all of the windows updates installed since the fresh install:

TimeCreated : 12/14/2016 12:20:47 AM
Message     : Installation Successful: Windows successfully installed the following update: Windows 10 IoT Core Production Bundle -
              OS 10.0.14393.576 update for 000-88 based devices

TimeCreated : 11/11/2016 12:21:28 AM
Message     : Installation Successful: Windows successfully installed the following update: Windows 10 IoT Core Production Bundle -
              OS 10.0.14393.448 update for 000-88 based devices

TimeCreated : 10/14/2016 2:45:11 PM
Message     : Installation Successful: Windows successfully installed the following update: Windows 10 IoT Core Production Bundle -
              OS 10.0.14393.321 update for 000-88 based devices

All replies (10)

Friday, June 2, 2017 8:11 PM âś…Answered

Sorry about the marked/unmarked - my computer keyboard is clicking links I hover over.

I finally got back to this and it is now fixed. I suspect the new version of PS installed yesterday (5.1.16212.1000) was responsible.


Thursday, January 26, 2017 6:02 PM

Hi JEdgar,

My apologies for the delay in responding but we have been unable to reproduce this issue on any of our builds.

When I run that cmdlet on my IotCore MBM:

PS C:\Data\Users\Administrator\Documents> get-localuser
Name           Enabled Description
            
Administrator  True    Built-in account for administering the computer/domain
DefaultAccount True    A user account managed by the system.
Guest          True    Built-in account for guest access to the computer/domain

On my RPi3:

PS C:\Data\Users\Administrator\Documents> get-localuserName               Enabled Description
                
Administrator      True    Built-in account for administering the computer/domain
DefaultAccount     True    A user account managed by the system.
Guest              True    Built-in account for guest access to the computer/domain
VSProfilingAccount True

Sincerely,

IoTGirl


Thursday, March 16, 2017 9:59 PM

hi again

I have the same issue

The 'Get-LocalUser' command was found in the module 'Microsoft.PowerShell.LocalAccounts', but the module could not be
loaded. For more information, run 'Import-Module Microsoft.PowerShell.LocalAccounts'.
    + CategoryInfo          : ObjectNotFound: (Get-LocalUser:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CouldNotAutoloadMatchingModule

And this is the latest build.

 BuildNumber  Version
     
    14393        10.0.14393

Regards

Kiran


Thursday, March 16, 2017 11:53 PM

Hi Kiran,

You will have to provide more detail as to how you are calling this.  Calling "PS C:\Data\Users\Administrator\Documents> get-localuser" is giving the results I have shown above.

Sincerely,

IoTGirl


Saturday, March 18, 2017 3:37 PM

hi IotGirl, just checking, is it the same build? 10.0.14393.953 of Windows Iot Core? 


Saturday, March 18, 2017 11:40 PM

Hi Kiran,

As that build just came out, neither you or I had that build when the question was asked.

Sincerely,

IoTGirl


Monday, March 20, 2017 10:41 PM

Looking through all my event logs shows I first noticed this problem on the OS version 10.0.14393.448.

I successfully used various Microsoft.PowerShell.LocalAccounts cmdlets on OS version 10.0.14393.321.
In fact I used Set-LocalUser to add a description to my user which is visible now using 'net user jedgar'

Just for the record My $psversiontable is:
[RaspberryPi2B]: PS C:\Data\Users\jedgar> $PSVersionTable

Name                           Value
                          
PSEdition                      Core
WSManStackVersion              3.0
PSVersion                      5.1.14393.1000
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
CLRVersion
BuildVersion                   10.0.14393.1000

Can someone please respond with their $psversiontable. The psversion and buildversion look strange to me.

Also for the record the fileinfo and md5 filehash of my file
C:\windows\system32\WindowsPowerShell\v1.0\Modules\Microsoft.PowerShell.LocalAccounts\1.0.0.0\Microsoft.PowerShell.LocalAccounts.dll
are as follows:

Mode                LastWriteTime         Length Name
                        
-a        10/5/2016   5:17 AM          47058 Microsoft.PowerShell.LocalAccounts.dll

Algorithm Hash                             filename
                            
MD5       AD5BD21FE3CA5A26BAFAC07A694618AA Microsoft.PowerShell.LocalAccounts.dll

Just execute the following 3 lines to get the fileinfo/filehashes of all the files in the module directory.

$localaccoutfiles = Get-ChildItem "$env:windir\System32\WindowsPowerShell\v1.0\Modules\Microsoft.PowerShell.LocalAccounts\1.0.0.0" -file
$localaccoutfiles | ft -au
Get-FileHash $localaccoutfiles.fullname -Algorithm md5 | select Algorithm,Hash,@{name='filename';expression={split-path $_.path -leaf}} | ft -au

All my log searching has turned up nothing else wrt this problem.
I have tried  get-winevent | where message like *localaccounts* and only find this failure.
I have examined all security and powershell logs in detail up to when I noticed the problem and see nothing interesting. 
I have not found any other update logs on windows IOT in C:\windows\Logs or anywhere else

Any suggestions what else to look for would be much appreciated.

   Jim Edgar


Friday, June 2, 2017 9:39 PM

Hi jedgar,

We were unable to get the failure you did so potentially there was an installation issue on your PC that was corrected by a later tools installer?

Sincerely,

IoTGirl


Saturday, June 3, 2017 3:01 AM

I am pretty sure it was solved by the following update: 16212.1000.rs_onecore_sigma.170531-1746 (UUP-CTv2) which was installed yesterday.

Looking at the timestamps of powershell.exe and Microsoft.PowerShell.LocalAccounts.dll both show a change yesterday.

> ls C:\windows\system32\windowspowershell\v1.0\Modules\Microsoft.PowerShell.LocalAccounts\1.0.0.0\Microsoft.PowerShell.LocalAccounts.dll,C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe

    Directory: C:\windows\system32\windowspowershell\v1.0\Modules\Microsoft.PowerShell.LocalAccounts\1.0.0.0

Mode                LastWriteTime         Length Name
                       
-a         6/1/2017  11:52 AM          91136 Microsoft.PowerShell.LocalAccounts.dll

    Directory: C:\Windows\System32\WindowsPowerShell\v1.0

Mode                LastWriteTime         Length Name
                       
-a         6/1/2017  12:05 PM         421888 powershell.exe

From what I am seeing posted though it looks like the update was a mistake - MS let an immature update out to even production systems.

I hope this does not mean I have to fresh install again. 


Saturday, June 3, 2017 4:28 AM

Hi jedgar,

Please take a look at https://social.msdn.microsoft.com/Forums/en-US/efa42b09-3390-48a8-8bd6-2038228dc085/unintentional-release-of-build?forum=WindowsIoT for details of the unintentional release.

Sincerely,

IoTGirl