Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Question
Monday, August 13, 2012 12:02 PM
Hello,
I get an error at PS script position convertTo-SecureString. The PS script is starting from a batchfile. The Batchfile is starting from a webservice!
# Import PSW:$textFromFile = Get-Content "\\zserver\c$\temp\encrypted_ysastagmespre.txt"$secpasswd = ConvertTO-SecureString $textFromFile
Error message at $secpasswd:
ConvertTo-SecureString : Key not valid for use in specified state.
At C:\Program Files\BuildPackage\IISClickOncePrepareDeploy.ps1:785 char:105
+ $secpasswd = Get-Content "\zserver\c$\temp\encrypted_ysastagmes
pre.txt" | ConvertTO-SecureString <<<<
+ CategoryInfo : InvalidArgument: (:) [ConvertTo-SecureString], C
ryptographicException
+ FullyQualifiedErrorId : ImportSecureString_InvalidArgument_Cryptographic
Error,Microsoft.PowerShell.Commands.ConvertToSecureStringCommand
I hope somebody can help me,
Thanks Horst MOSS 2007 Farm; MOSS 2010 Farm; TFS 2010; IIS 7.5
All replies (5)
Tuesday, August 14, 2012 5:38 AM âś…Answered | 1 vote
You can use predefined key,if you use different machines account:
Monday, August 13, 2012 12:09 PM
shouldn't that be ConvertFrom-SecureString ??
Monday, August 13, 2012 12:12 PM
Try:
$secpasswd = ConvertTO-SecureString $textFromFile -asplaintext -Force
Grant Ward, a.k.a. Bigteddy
Monday, August 13, 2012 12:20 PM
Hello,
In another scipt I have done this, to generate the file with key password:
$secpasswd = ConvertTo-SecureString -String "Pass$$word" -AsPlainText -ForceConvertFrom-SecureString -SecureString $secpasswd | out-file "\\zserver\c$\temp\encrypted_ysastagmespre.txt
In the script, where i start a porcess with the username and password, looks like this:
$textFromFile = Get-Content "\\zserver\c$\temp\encrypted_ysastagmespre.txt"$secpasswd = ConvertTO-SecureString $textFromFile$svcCredentials = New-Object System.Management.Automation.PSCredential("domian\username", $secpasswd)$Params = "-Sign", ` "`"C:\Temp\Client.Shell.application`"", ` "-Certfile", "`"C:\Temp\TemporaryKey.pfx`"" Start-Process "C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\NETFX 4.0 Tools\mage.exe" -ArgumentList $Params -LoadUserProfile -Credential $svcCredentials -Wait # -WindowStyle Hidden; $?
I am not a powershell expert, sorry about this,
Thanks,
Thanks Horst MOSS 2007 Farm; MOSS 2010 Farm; TFS 2010; IIS 7.5
Tuesday, August 14, 2012 8:31 AM
Hello Kazun,
That was the right link, now it is working fine.
Thank you very much!!!
Horst
Thanks Horst MOSS 2007 Farm; MOSS 2010 Farm; TFS 2010; IIS 7.5