Hello all,
I am relatively new to Powershell scripting and needed help with the following question. For the experienced programmers certainly an easy one.
Background to the request: Our software distribution unfortunately only allows 32 bit Powershell to be run. The command I want to execute was
by an ALIAS and the call of the 64 bit Powershell. The goal is to create a local admin account on a client PC for emergencies where
where a access via remote login ist no longer posssible. i have tried to execute the following command in a 32 bit Powershell:
Set-Alias Start-PowerShell64 “$env:windir\sysnative\WindowsPowerShell\v1.0\powershell.exe”
Start-PowerShell64 Set-ExecutionPolicy -ExecutionPolicy Bypass
Start-PowerShell64 New-LocalUser -Name ‘NewAdminUser’ -Password (Start-PowerShell64 convertto-securestring “12345678” -asplaintext -force)
Start-PowerShell64 Add-LocalGroupMember -Group “Administratoren” -Member “NewAdminUser”
Unfortunately, when running the New-Localuser command on the -Password parameter, the command fails with the following error message:
New-LocalUser : The “Password” parameter cannot be bound. The value “System.Security.SecureString” of type
“System.String” cannot be converted to “System.Security.SecureString” type.
In line:1 character:44
- … w-LocalUser -Name NewAdminUser -Password System.Security.SecureString
-
+ CategoryInfo : InvalidArgument: (:) [New-LocalUser], ParameterBindingException + FullyQualifiedErrorId : CannotConvertArgumentNoMessage,Microsoft.PowerShell.Commands.NewLocalUserCommand
Of course there are other ways to create a local admin account, however I would be interested in the solution to this problem.
Thank you very much for your help.