This topic contains 5 replies, has 3 voices, and was last updated by
September 1, 2019 at 1:46 pm #174043
$Username = 'domain\username'
$Password = 'password'
$pass = ConvertTo-SecureString -AsPlainText $Password -Force
$SecureString = $pass
# Users you password securly
$MySecureCreds = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList Username,$SecureString
gwmi win32_service –credential $MySecureCreds
I get : This command cannot be run due to the error : the user name or password is incorrect
If I use an admin username and password it work!
Can someone help?
September 1, 2019 at 5:42 pm #174058ParticipantTopics: 7Replies: 5Points: 63Rank: Member
In your ArgumentList you are missing a $ in front of Username.
September 2, 2019 at 3:53 am #174115
The script I had was written with the $ before the Username
Sorry, I mistake the transcript.
Same issue, not woriking, always get This command cannot be run du to the error : the user name or password is incorrect.
Work with administrator!
September 3, 2019 at 1:39 pm #174292
Just to help somebodey taht ever come here for the same probleme!
my internal domain name was : myinternalverylongdomainname.local
So my username are normally : myinternalverylongdomainname\username
In this case, the pre-windows 2000 name domain was "myinternal"
So for the powershell get-credential to work I had to use myinternal\username
Maybe it by design, but on the 350 domains that I manage it the only one with a such long internal domain name.
September 3, 2019 at 3:43 pm #174319ParticipantTopics: 0Replies: 100Points: 363Rank: Contributor
How long is the domain name and user name each? Based on my testing Get-Credential is supporting up to 83 characters for the user and domain name. This was validated using UserPrincipalName and NT Login (Domain\UserName).
September 3, 2019 at 6:35 pm #174375
20 for domain name and 10 for username
I dont have any such long name like that on any of my other setup
I spent a lot of time before I figure it out.
I will try to reproduce this on a temp setup this week to see.
You must be logged in to reply to this topic.