Share via


Failure to set the values of variables designating credentials of the local Administrator account

Question

Tuesday, May 14, 2019 6:46 AM

I encountered an error with running PowerShell.

Please see the attached picture.
"Failure to set the values of variables designating credentials of the local Administrator account Exercise 1 Task 2 Step 6 error message.PNG"

Attached also please find the pdf files showing the steps I have taken.

Please advise.

Thank you very much.

Below is the error message:

PS Azure:\
Azure:/

PS Azure:\ $adminUsername = 'Student'
Azure:/

PS Azure:\ $adminPassword = 'Pa55w.rd1234'
Azure:/

PS Azure:\ $adminCreds = New-Object PSCredential $adminUsername, ($adminPassword | ConvertTo-SecureString -AsPlainText -Force)

ConvertTo-SecureString : Cannot bind argument to parameter 'String' because it is null.
At line:1 char:73

  • ... ername, ($adminPassword | ConvertTo-SecureString -AsPlainText -Force)
    +                 
  • CategoryInfo          : InvalidData: (:) [ConvertTo-SecureString], ParameterBindingValidationException
  • FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.ConvertToSecureStringCommand

New-Object : Exception calling ".ctor" with "2" argument(s): "Cannot process argument because the value of argument "userName" is not valid. Change the value of the "userName" argument and run the operation again."
At line:1 char:15

  • ... dminCreds = New-Object PSCredential $adminUsername, ($adminPassword | ...
    +                 
  • CategoryInfo          : InvalidOperation: (:) [New-Object], MethodInvocationException
  • FullyQualifiedErrorId : ConstructorInvokedThrowException,Microsoft.PowerShell.Commands.NewObjectCommand

All replies (3)

Tuesday, May 14, 2019 6:56 AM âś…Answered

Hi, 

Can you try the below PowerShell script?

$adminUsername = 'Student'
$adminPassword = ConvertTo-SecureString 'Pa55w.rd1234' -AsPlainText -Force
$adminCreds = New-Object PSCredential $adminUsername, $adminPassword

Regards, 

Msrini


Tuesday, May 14, 2019 7:16 AM

Thanks.

Your commands work.

Looks like breaking them up work.

Thank you very much for your help.


Tuesday, May 14, 2019 7:34 AM

Awesome. Please mark the response as answered, so that others in the community who are looking for similar question, can benefit from it.

Regards, 

Msrini