Mark Minasi's Reader Forum
Mark Minasi's Reader Forum
Home | Profile | Register | Active Topics | Active Polls | Members | Search | FAQ | Minasi Forum RSS Feed
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 HALP! Questions on Windows and Windows Server
 Scripting
 Help with Extended ASCII in PowerShell
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

philrobeson
Here To Stay

USA
256 Posts
Status: offline

Posted - 06/09/2011 :  2:47:22 PM  Show Profile  Reply with Quote
We use a lot of Extended characters in passwords on our service accounts. I have a script that can change the service account password, but I've yet to figure out, via code, how to put extended characters in there. For example, the line of code I use in my script that changes the password is this:

$objUser.psbase.invoke("SetPassword", 'JoeBobBilly')

However, let's say I'd like it to start with é (which is <Alt>130
How do I do this in the above code?

I did search the web and can't find anything. I sent the "scriptiing guys" this same question last week and they've not answered...anyone have any ideas? Thanks.

Phil Robeson
MIS/M

jhicks
Here To Stay

USA
283 Posts
Status: offline

Posted - 06/09/2011 :  4:37:06 PM  Show Profile  Visit jhicks's Homepage  Reply with Quote
In PowerShell you can use the [CHAR] class. For example, to get <alt>130 in PowerShell you would type: [char]233

Here's a one line command to list all the characters up to 512

1..512 | foreach {"{0} = {1}" -f $_, ($_ -as [char])}

Once you know the character values, you can build a password. Here's one way:

PS E:\> $pass=""
PS E:\> 0..7 | foreach {$pass+=([char](Get-random -min 160 -max 200))}
PS E:\> $pass
³±¯»¾¥Ã£

Now, you would still need to know the ALT equivalent so you can enter it. But you can use Charmap.exe to figure that out.

Jeffery Hicks
Windows PowerShell MVP

http://jdhitsolutions.com.blog
http://twitter.com/JeffHicks
http://www.ScriptingGeek.com
Now Available: Managing Active Directory with Windows PowerShell: TFM 2nd ed.
Go to Top of Page

philrobeson
Here To Stay

USA
256 Posts
Status: offline

Posted - 06/10/2011 :  08:16:06 AM  Show Profile  Reply with Quote
AWESOME! Thanks, Jeff!!

Phil Robeson
MIS/M
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
Mark Minasi's Reader Forum © 2002-2011 Mark Minasi Go To Top Of Page
This page was generated in 0.16 seconds. Snitz Forums 2000