This topic contains 6 replies, has 4 voices, and was last updated by
March 6, 2018 at 3:45 pm #95248
Someone ran a command to add a local user to 900 computers last week, and they pasted in an apostrophe at the end of the user name by mistake. It's now:
I can't delete these using DOS or PowerShell because it's coming back saying "The username doesn't exist". I'm guessing because the apostrophe is being seen as part of the command and not the username.
Can anyone help me with a PowerShell (or even DOS) command structure that I can use which will see the ' as part of the username?
Thanks so much!
March 6, 2018 at 3:47 pm #95250KeymasterPoints: 1,811Rank: Community Hero
Sorry. Couldn't help it.
PowerShell shouldn't have a problem so long as you delimit the entire username in double quotes. And the local SAM should be okay with it since apostrophes occur all the time in names.
What command are you trying? What error are you getting?
March 7, 2018 at 3:18 am #95296
You're right. What's happening is they use Kaseya to run scripts across multiple customer networks, and since its acting as a middleman it's goofing up the syntax thranslation somehow.
It normally handles PowerShell pretty well. In this case it's barfing all over it.
Thanks for your reply though. It confirmed that I had the right idea. Appreciated.
March 6, 2018 at 8:27 pm #95286ParticipantPoints: -17Rank: Member
Would doing that to 900 computers in some Prod environments be a resume generating moment, I'd be worried unleashing that unless I had tested it a fair few times
March 7, 2018 at 3:15 am #95293
Which is why I'm taking over. Not a very productive response but thanks for trying.
March 7, 2018 at 3:24 am #95301KeymasterPoints: 1,811Rank: Community Hero
Jeez I wish I had a Kaseya install to work with. I wonder if escaping the apostrophe would help?
March 7, 2018 at 3:54 am #95308ParticipantPoints: 1Rank: Member
Random thought, have you tried either setting the user name as a variable so the apostrophe might not cause so much of an issue? Or using a like query where you have everything but the apostrophe? Just thinking of ways you can achieve the same result without having to directly reference the apostrophe. Just because you know the actual account name doesn't mean you have to directly reference it.
A quick test in PowerShell 5.1 I was able to create/query/remove the user account Test' when using double quotes.
Additional random thought: no clue what Kaseya is but maybe you need to use regex for the account i.e. UserName\'
The topic ‘Urgent help needed deleting local username with apostrophe’ is closed to new replies.