![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
|
Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
br> br> |
| |||||||
![]() |
| | Thread Tools | Display Modes |
| | #1 (permalink) |
| Guest | How to view the value of a Secure.string variable Hello, I am asking a user to enter their password for use in a script. I am saying $password = Read-Host "Enter Password" - asSecureString This now puts it into a SecureString variable. When I call the variable, it just returns System.Security.SecureString. Does anyone know how to extract the actual string from the variable? Thanks, Flea# -- http://fleasharp.blogspot.com/ |
My System Specs![]() |
| | #2 (permalink) |
| Guest | Re: How to view the value of a Secure.string variable Try this function GetSecurePass ($SecurePassword) { $Ptr = [System.Runtime.InteropServices.Marshal]::SecureStringToCoTaskMemUnicode($SecurePassword) $pwd = [System.Runtime.InteropServices.Marshal]::PtrToStringUni($Ptr) [System.Runtime.InteropServices.Marshal]::ZeroFreeCoTaskMemUnicode($Ptr) $pwd } GetSecurePass $password Brandon Shell --------------- Blog: http://www.bsonposh.com/ PSH Scripts Project: www.codeplex.com/psobject F> Hello, F> F> I am asking a user to enter their password for use in a script. I am F> saying $password = Read-Host "Enter Password" - asSecureString F> F> This now puts it into a SecureString variable. When I call the F> variable, it just returns System.Security.SecureString. Does anyone F> know how to extract the actual string from the variable? F> F> Thanks, F> Flea# |
My System Specs![]() |
| | #3 (permalink) |
| Guest | Re: How to view the value of a Secure.string variable $password = Read-Host "Enter Password" -asSecureString [Runtime.InteropServices.Marshal]::PtrToStringAuto[Runtime.InteropServices.Marshal]::SecureStringToBSTR($password)) -- Kiron |
My System Specs![]() |
| | #4 (permalink) | ||||||||||||||||||||||||||||||||||||
| Guest | Re: How to view the value of a Secure.string variable You've missed the opening parenthesis ![]()
----- Shay Levi $cript Fanatic http://scriptolog.blogspot.com
| ||||||||||||||||||||||||||||||||||||
My System Specs![]() | |||||||||||||||||||||||||||||||||||||
| | #5 (permalink) |
| Guest | Re: How to view the value of a Secure.string variable Last post had a typo: [Runtime.InteropServices.Marshal]::PtrToStringAuto([Runtime.InteropServices.Marshal]::SecureStringToBSTR($password)) -- Kiron |
My System Specs![]() |
| | #6 (permalink) |
| Guest | Re: How to view the value of a Secure.string variable |
My System Specs![]() |
| | #7 (permalink) |
| Guest | Re: How to view the value of a Secure.string variable Thanks Shay. -- Kiron |
My System Specs![]() |
| | #8 (permalink) | ||||||||||||
| Guest | Re: How to view the value of a Secure.string variable That worked perfectly, thanks Kiron. -- http://fleasharp.blogspot.com/ "Kiron" wrote:
| ||||||||||||
My System Specs![]() | |||||||||||||
| | #9 (permalink) | ||||||||||||
| Guest | Re: How to view the value of a Secure.string variable On Jan 29, 12:20*am, Brandon Shell [MVP] <a_bshell.m...@xxxxxx> wrote:
the current working directory, so if you use this variable name, it overwrites the $pwd automatic variable. -aleksandar http://powershellers.blogspot.com | ||||||||||||
My System Specs![]() | |||||||||||||
| | #10 (permalink) | ||||||||||||||||||||||||
| Guest | Re: How to view the value of a Secure.string variable Duh... I usually used $password so I just change to $pwd when I pasted without thinking. Good catch. Brandon Shell --------------- Blog: http://www.bsonposh.com/ PSH Scripts Project: www.codeplex.com/psobject a> On Jan 29, 12:20 am, Brandon Shell [MVP] <a_bshell.m...@xxxxxx> a> wrote: a>
a> the current working directory, so if you use this variable name, it a> overwrites the $pwd automatic variable. a> a> -aleksandar a> http://powershellers.blogspot.com | ||||||||||||||||||||||||
My System Specs![]() | |||||||||||||||||||||||||
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Find a string within a variable string | Edward.A.Gonzalez | PowerShell | 4 | 08-15-2008 08:13 AM |
| Re: how to tokenize a string into a variable via regex | Kiron | PowerShell | 1 | 07-14-2008 02:39 PM |
| SSIS - string variable! | Daniel | .NET General | 0 | 05-15-2008 05:53 AM |
| Subject: using a Variable with/in a string | DonP | PowerShell | 2 | 02-27-2008 02:11 PM |
| Using group-object with a variable string | Marco Shaw | PowerShell | 4 | 12-13-2006 10:47 AM |