2013-05-07 4 views
2

여러 번 사용하려면 자격 증명을 powershell에 저장해야합니다. 여기에 StackOverflow에 대한 예를 많이 있습니다, 그래서 불행하게도 하나서버에서 powershell 자격 증명이 거부되었습니다.

$tmpCred = Get-Credential 
$tmpCred.Password | ConvertFrom-SecureString | Set-Content "pwd.dat" 
$password = Get-Content "pwd.dat" | ConvertTo-SecureString 
$credential = New-Object System.Management.Automation.PsCredential "myDomain\myUser", $password 

Get-ADUser -Credential $credential 

했다 나는이 오류가 나는 내가 가진 분명히 잘못 아무것도 볼 수 없습니다

Get-ADUser : The server has rejected the client credentials. 
At line:5 char:11 
+ Get-ADUser <<<< "xxx" -Credential $credential 
    + CategoryInfo   : NotSpecified: (xxx:ADUser) [Get-ADUser], AuthenticationException 
    + FullyQualifiedErrorId : The server has rejected the client credentials.,Microsoft.ActiveDirectory.Management.Commands.GetADUser 

답변

4

해결책을 찾을 수 없습니다 귀하의 코드, 나는 이것이 당신이 여러 장소에서 사용해야 할 필요가 있음을 언급하면서 그것을 사용하는 방법의 예일뿐입니다. 자격 증명 주위에 전달하는

Get-ADUser -Credential $tmpCred 

하나의 옵션은 다음과 같습니다 그냥 정말 당신이 자격 증명이 디스크에 지속되기 전에 일을 증명해야 다음을 사용하여 확인할 수 있습니다 실패 보안 문자열의 저장이 있는지 확인합니다 Get-Credentials 호출에서 반환되고 $tmpCred 변수에 저장된 [System.Management.Automation.PSCredential] 유형을 사용하여 파일 또는 보안 문자열이 아닌

당신은 일시적으로 암호가 제대로 해독되었는지 확인하는 방법 GetNetworkCredentials()에 전화를 추가 할 수 있습니다, 다음은 암호화되지 않은 사용자 이름 및 암호가 표시됩니다 :

$tmpCred.GetNetworkCredential().Username 
$tmpCred.GetNetworkCredential().Password 

희망하는 데 도움이 ...

관련 문제