'New-localuser with joined string password

What is going wrong with this:

$pass= "kissa"+"koira"
$pw= ConvertTo-SecureString $pass -AsPlainText -Force

#Create local user
New-LocalUser -Name $username -Password $pw -UserMayNotChangePassword -AccountNeverExpires -PasswordNeverExpires

It creates a user, does not nag about anything. But when I try to login the password is not accepted.

Password should be kissakoira. This is of over simplified example, im trying to create a password with three variables, but even this simple joined string does not work. Its not password complexity as plain kissa or koira work, but not the joined string.



Solution 1:[1]

This seems to work:

$pw="kissa"+"koira"| ConvertTo-SecureString -AsPlainText -Force

#Create local user New-LocalUser -Name $username -Password $pw -UserMayNotChangePassword -AccountNeverExpires -PasswordNeverExpires

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Marko Mård