I am trying to make a script that creates users. But it gives me an error. Could you help me?
The idea is to create a script that, when executed, automatically creates the users, with name, password (the default must be the same username) and description.
The script then has to assign the users to a local group.
--Source code--
#Script para crear usuarios en los terminales de Gerencia;
Clear-Host;
$PassG01= "dawsG01"
New-LocalUser -Name "dawsG01" -Password $PassG01 -Description "Usuario de Gerencia";
Add-LocalGroupMember -Group "Administradores" -Member "dawsG01";
--error text--
New-LocalUser : No se puede enlazar el parámetro 'Password'. No se puede convertir el valor "dawsG01" de tipo "System.String" al tipo
"System.Security.SecureString".
En línea: 4 Carácter: 41
+ New-LocalUser -Name "dawsG01" -Password $PassG01 -Description "Usuari ...
+ ~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [New-LocalUser], ParameterBindingException
+ FullyQualifiedErrorId : CannotConvertArgumentNoMessage,Microsoft.PowerShell.Commands.NewLocalUserCommand
Add-LocalGroupMember : WIN-JBOS5873GKP\dawsG01 ya es un miembro del grupo Administradores.
En línea: 5 Carácter: 1
+ Add-LocalGroupMember -Group "Administradores" -Member "dawsG01";
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ResourceExists: (Administradores:String) [Add-LocalGroupMember], MemberExistsException
+ FullyQualifiedErrorId : MemberExists,Microsoft.PowerShell.Commands.AddLocalGroupMemberCommand
I have tried saving the default passwords in variables and also entering them directly as a string , but I get the same error.
Thanks in advance.