보안 된 파일에 자격 증명을 저장하기 위해이 게시물에서 설명한 것과 같은 작업을 수행 했으므로 자동화 된 프로세스에서 원격 PS를 실행할 수 있습니다 스크립트를 통해 Invoke-command : http://blogs.technet.com/b/robcost/archive/2008/05/01/powershell-tip-storing-and-using-password-credentials.aspxpowershell에서 재사용 할 자격 증명을 저장하고 오류 ConvertTo-SecureString : 지정된 상태에서 사용하기에 키가 올바르지 않음
이것은 내 계정에서 실행하면 좋습니다 - 암호는 암호화 된 파일에서 읽은 후 Invoke-Command로 전달되고 모든 항목이 정상입니다.
오늘 내 스크립트가 황금 시간대에 준비되었을 때 자동화 된 프로세스에서 사용할 Windows 계정에서 스크립트를 실행하려고 시도했지만 스크립트에서 파일에서 보안 된 암호를 읽으려고 시도하는 동안이 오류가 발생했습니다 :
ConvertTo-SecureString : Key not valid for use in specified state.
At \\remoted\script.ps1:210 char:87
+ $password = get-content $PathToFolderWithCredentials\pass.txt | convertto-sec
urestring <<<<
+ CategoryInfo : InvalidArgument: (:) [ConvertTo-SecureString], C
ryptographicException
+ FullyQualifiedErrorId : ImportSecureString_InvalidArgument_Cryptographic
Error,Microsoft.PowerShell.Commands.ConvertToSecureStringCommand
내 직장 동료가 자신의 계정으로 실행하도록 요청했는데 동일한 오류가 발생했습니다.
$login= get-content $PathToFolderWithCredentials\login.txt
$password = get-content $PathToFolderWithCredentials\pass.txt | convertto-securestring
$credentials = new-object -typename System.Management.Automation.PSCredential -argumentlist $login,$password
:이 호출-명령에 사용하도록 읽을 수있는 자동화 된 프로세스로 실행하는 스크립트 코드가
$PathToFolderWithCredentials = "\\path\removed"
write-host "Enter login as domain\login:"
read-host | out-file $PathToFolderWithCredentials\login.txt
write-host "Enter password:"
read-host -assecurestring | convertfrom-securestring | out-file $PathToFolderWithCredentials\pass.txt
write-host "*** Credentials have been saved to $pathtofolder ***"
입니다 :
이
내가 자격 증명을 저장하기 위해 사용하고있는 코드입니다줄에 오류가 발생했습니다. $ password = get-content $ PathToFolderWithCredentials \ pass.txt | convertto-securestring
아이디어가 있으십니까?
"ConvertFrom-SecureString cmdlet은 Windows 표준 Data Protection API를 사용하여이 데이터를 암호화하므로 사용자 계정 만 해당 내용을 적절히 해독 할 수 있습니다." 그것이 작동하지 않는 이유는 무엇입니까 ... 어떤 아이디어가 다른 Windows 계정에 의해 해독 될 수있는 암호를 저장하는 가장 좋은 방법이 될 것이라고 생각하십니까? – mishkin
이 블로그 게시물도 매우 유용했습니다 http://powertoe.wordpress.com/2011/06/05/storing-passwords-to-disk-in-powershell-with-machine-based-encryption/ – mishkin
그리고 저는 초보자와 고급 사용자 모두를위한 "Powershell Cookbook"- goob book을 읽는 것이 좋습니다. 그것은 이것과 많은 다른 것들을 다룹니다. – manojlds