2017-02-03 3 views
1

: $header 인코딩 이름 및 암호를 포함파워 쉘 호출 - WebRequest를 스마트 카드의 인증을 사용하거나, 기존 인증 데이터 이제 다음과 같이 I-출할 WebRequest 클래스를 사용하는 데 틸

Invoke-WebRequest -u $url -header $header 

있다.

웹 사이트가 Active Directory와 작업을 이동하기 때문에

는 스마트 카드의 데이터는 이제

가 어떻게 스마트 카드 자격 증명을 Invoke-WebRequest을 사용할 수있는 액세스를 인증하는 데 사용됩니다?

감사합니다.

답변

1

스마트 카드 사용은 기본적으로 인증서가 필요한 웹 사이트와 동일하게 취급됩니다.

스마트 카드 인증을 사용하여 SharePoint에서 파일을 다운로드하려면 아래 코드를 사용하십시오. 요구 사항을 충족 시키려면 Invoke-WebRequest을 수정하면됩니다.

Add-Type -AssemblyName System.Security 

# Filtering for cert requirements... 
$ValidCerts = [System.Security.Cryptography.X509Certificates.X509Certificate2[]](dir Cert:\CurrentUser\My | where { $_.NotAfter -gt (Get-Date) }) 

# You could check $ValidCerts, and not do this prompt if it only contains 1... 
$Cert = [System.Security.Cryptography.X509Certificates.X509Certificate2UI]::SelectFromCollection(
    $ValidCerts, 
    'Choose a certificate', 
    'Choose a certificate', 
    'SingleSelection' 
) | select -First 1 

$WebRequestParams = @{ 
    Uri = $Url  # Uri to file to download 
    OutFile = $Path # Path to where file should be downloaded (include filename) 
    Certificate = $Cert 
} 
Invoke-WebRequest @WebRequestParams 
+0

안녕하세요, 어떻게 든 작동하지 않습니다 ... 여전히 잘못된 자격 증명을 보낸 응답을받는 중입니다. – mrGo