It works for me
You can use this way to save the encrypted password (alternative way)
Powershell Store Encrypted Password for auto login
$credential = Get-Credential
$credential.password |ConvertFrom-SecureString |set-Content C:\Users\<user_name>\encrypted_password.txt
$encrypted = Get-Content C:\Users\<user_name>\encrypted_password.txt | ConvertTo-SecureString
$dom_user = "domain\user_name"
$credential = New-Object System.Management.Automation.PsCredential($dom_user, $encrypted)
Add-NcCredential -Controller <controller> -credential $credential