Click here to Skip to main content
Rate this: bad
Please Sign up or sign in to vote.
See more: C# PowerShell
I have got a build error in the following code....
string password = "Global12$";
string userName = @"myindia.local\Administrator";
SecureString ss = ConvertToSecureString(password);
This is the error message
The name 'ConvertToSecureString' does not exist in the current context
I don't know how to solve this? Which namespace is missing? Any help on this would be great.
Thanks & Regards
Posted 15-Jun-12 2:51am
Edited 17-Jun-12 19:20pm
ryanb31 at 15-Jun-12 8:58am
A quick google search indicates using ConvertTo-SecureString. Have you tried that?
Sebastian T Xavier at 15-Jun-12 9:22am
If you can show some examples of this , that would be great!!!
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Not sure if this is what you're looking for, but try this link:
ConvertToSecureString Class[^] on MSDN.
It has some examples there.
Edited: This can't be the right answer Smile | :)
On second thought look at the comments at the bottom here[^]
Maybe that's where this mysterious method came from Wink | ;)
private SecureString ConvertToSecureString(string value)
    SecureString ret = new SecureString();
    foreach (char c in value)
    return ret;
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

ConvertToSecureString is a private method , which you need to write in your own class.
As mentioned[^], you need to write your own version of ConvertToSecureString method.
Rushikesh Joshi
Sebastian T Xavier at 18-Jun-12 1:19am
Thanks for your reply. But I think , I am looking for another method. Please have a look at the following URL.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Advertise | Privacy | Mobile
Web01 | 2.8.141022.2 | Last Updated 18 Jun 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100