Welcome to OCS Inventory NG community support, where you can ask questions and receive answers from other members of the community.

Please ask questions only in English or French.

Release 2.11.1 available

The official documentation can be found on http://wiki.ocsinventory-ng.org. Read it before asking your question.

How to change password of a windows 10 local user

Hello,

I am trying to change the password of a Windows 10 local user using OCS. I am running an OCS  NG Unix server 2.6 and OCS NG Windows Agent 2.4.0.0

I am encrypting the password using Powershell and I am trying to change the password using Microsoft.PowerShell.LocalAccounts module with Set-LocalUser command.

I know that I can change the password using net user username password but with this option, I have to send the password in clear text and is not a valid solution for me.

I have opened a cmd as SYSTEM account and I can change the password successfully but if I run the same script using OCS deploy it says

"The term 'Set-LocalUser' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again."

I have even tried to install/import the module using OCS deploy. The error that I get is:

'C:\Windows\System32\WindowsPowerShell\v1.0\Modules\Microsoft.PowerShell.LocalAccounts' was not loaded because no valid module file was found in any module directory.

At line:1 char:1

+ Import-Module -Name C:\Windows\System32\WindowsPowerShell\v1.0\Module ...

+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : ResourceUnavailable: (C:\Windows\Syst...l.LocalAccounts:String) [Import-Module], FileNot
FoundException

    + FullyQualifiedErrorId : Modules_ModuleNotFound,Microsoft.PowerShell.Commands.ImportModuleCommand

Did anyone encountered this issue or use another way to change the password in a secure way?
in OCS Inventory NG server for Unix by (730 points)

2 Answers

0 votes
 
Best answer
Thank you very much sokatra for pointing me in the right direction and showing me that OCS runs under 32bit

To change a local windows user password i have first encrypted the password into a file

ConvertFrom-SecureString -SecureString ( Read-Host -AsSecureString) -Key (1..16) | Set-Content Passwd.txt

I have to run the 64bit PowerShell

and I have changed with the following command:

c:\windows\sysnative\WindowsPowerShell\v1.0\powershell.exe "Set-LocalUser -Name 'username' -Password $(Get-Content 'Passwd.txt' | ConvertTo-SecureString -Key (1..16))"
by (730 points)
+1 vote
Try to start powershell with tis command

C:\Windows\SysNative\WindowsPowerShell\v1.0\PowerShell.exe

source

https://www.madwithpowershell.com/2015/06/64-bit-vs-32-bit-powershell.html

Kind regards
by (22.6k points)
 
Powered by Question2Answer
...