When trying to access an FTP site, I can use a simple text password in the credentials, and it works fine, but when I use SecureString, it cannot authenticate. Examples:
$pw = "mypw"
$ftp = [system.net.ftpwebrequest] [system.net.webrequest]::create("ftp:myserver")
$ftp.Credentials = new-object system.net.networkcredential("myuid", $pw)
works great. But the following errors
$pw = "mypw"
$ftp = [system.net.ftpwebrequest] [system.net.webrequest]::create("ftp:myserver")
$ss = convertto-securestring -asplaintext -force $pw
$ftp.Credentials = new-object system.net.networkcredential("myuid", $ss)
But this fails authentication. What? I do not understand?
(BTW I know that I do not need the plaintext pw in my script. This is just an example.)
source
share