Try single quote "PROD\username" => 'PROD\username'
Powershell "Cannot process argument"
I am running into below error while trying to run this piece of code, can someone throw some light on what I am missing here? Thanks!
$SecurePassword = ConvertTo-SecureString "password" -AsPlainText -Force -ErrorAction Stop $SSCred = New-Object System.Management.Automation.PSCredential ("PROD\username", $SecurePassword) -ErrorAction Stop Write-Host "$(Get-date): Done Secret Server Login" $AzureProdLock = Get-SecretServerCredential -SamAccountName pjob9001 -OperatorCredentials $SSCred -Verbose:$True -ErrorAction Stop $Null = Connect-AzAccount -ServicePrincipal -Credential $AzureProdLock -Tenant "tenantId" -ErrorAction Stop -WarningAction SilentlyContinue
"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.""
Sign in to comment
1 additional answer
Sort by: Most helpful
PowerShell protects access to variables, aliases, functions, and PowerShell drives (PSDrives) by limiting where they can be read and changed. PowerShell uses scope rules to ensure that you do not inadvertently change an item that should not be changed.
In the second line for PROD\ avoid double quotes ("PROD\username") and replace them with single quotes ( 'PROD\username' )
Hope this answers all your queries, if not please do repost back.
If an Answer is helpful, please click "Accept Answer" and upvote it : )