2013-03-04 1 views
2

은 내가 파워 쉘의 PS1 파일 내에서 netsh를 HTTP를 사용하여 sslcert을 추가하려고하지만 던지는 오류 유지 :netsh http sslcert가 Powershell ps1 파일에서 오류를 발생시키는 이유는 무엇입니까?

$guid = [guid]::NewGuid() 

netsh http add sslcert ipport=0.0.0.0:443 certhash=5758B8D8248AA8B4E91DAA46F069CC1C39ABA718 appid={$guid} 


'JABnAHUAaQBkAA' is not a valid argument for this command. 
The syntax supplied for this command is not valid. Check help for the correct syntax. 

    Usage: add sslcert [ipport=]<IP Address:port> 
     [certhash=]<string> 
     [appid=]<GUID> 
     [[certstorename=]<string> 
      [verifyclientcertrevocation=]enable|disable 
      [verifyrevocationwithcachedclientcertonly=]enable|disable 
      [usagecheck=]enable|disable 
      [revocationfreshnesstime=]<u-int> 
      [urlretrievaltimeout=]<u-int> 
      [sslctlidentifier=]<string> 
      [sslctlstorename=]<string> 
      [dsmapperusage=]enable|disable 
      [clientcertnegotiation=]enable|disable] 

매개 변수 :

Tag      Value 

    ipport     - IP address and port for the binding. 
    certhash    - The SHA hash of the certificate. This hash 
           is 20 bytes long and specified as a hex 
           string. 
    appid     - GUID to identify the owning application. 
    certstorename   - Store name for the certificate. Defaults 
           to MY. Certificate must be stored in the 
           local machine context. 
    verifyclientcertrevocation - Turns on/off verification of revocation 
           of client certificates. 
    verifyrevocationwithcachedclientcertonly - Turns on/off usage of 
               only cached client 
               certificate for revocation checking. 
    usagecheck    - Turns on/off usage check. Default is enabled. 
    revocationfreshnesstime - Time interval to check for an updated 
           certificate revocation list (CRL). If this 
           value is 0, then the new CRL is updated 
           only if the previous one expires. (in 
           seconds) 
    urlretrievaltimeout  - Timeout on attempt to retrieve certificate 
           revocation list for the remote URL. 
           (in milliseconds) 
    sslctlidentifier  - List the certificate issuers that can 
           be trusted. This list can be a subset of 
           the certificate issuers that are trusted 
           by the machine. 
    sslctlstorename   - Store name under LOCAL_MACHINE where 
           SslCtlIdentifier is stored. 
    dsmapperusage   - Turns on/off DS mappers. Default is 
           disabled. 
    clientcertnegotiation - Turns on/off negotiation of certificate. 
           Default is disabled. 

Remarks: adds a new SSL server certificate binding and corresponding client 
     certificate policies for an IP address and port. 

Examples: 

    add sslcert ipport=1.1.1.1:443 certhash=0102030405060708090A0B0C0D0E0F1011121314 appid={00112233-4455-6677-8899 
-AABBCCDDEEFF} 

내가 잘못 될 수도 있습니다,하지만 나는 그것을 믿는다 내 powershell 스크립트 파일에서 appid GUID를 지정하는 방법에 대해 설명합니다. 누군가가 오류를 해결할 수 있도록 도와 주시겠습니까?

답변

8

그것은 PowerShell을 cmd를 명령을 구문 분석하는 방식에 문제가 있습니다. 여기 &이 매개 변수를 호출 프로그램에 사용되는 코드 아래

$guid = [guid]::NewGuid() 
$Command = "http add sslcert ipport=0.0.0.0:443 certhash=5758B8D8248AA8B4E91DAA46F069CC1C39ABA718 appid={$guid}" 
$Command | netsh 
+0

Perfect! 정확히 내가 필요로하는 것, 고마워. –

2

이 작동하고 "appid={$guid}"은 문자열 값을 전달합니다 이 성공적으로 명령을 실행합니다.

& netsh http add sslcert ipport=0.0.0.0:443 certhash=5758B8D8248AA8B4E91DAA46F069CC1C39ABA718 "appid={$guid}" 
1

오류의 원인은 중괄호를 각각 백틱 (')으로 이스케이프해야한다는 것입니다.

다음 명령은 파워 쉘 명령 행에서 작동합니다

이 파워 쉘 commadline에서 작동합니다

$AppId = [Guid]::NewGuid().Guid 
$Hash = "209966E2BEDA57E3DB74FD4B1E7266F43EB7B56D" 

netsh http add sslcert ipport=0.0.0.0:8000 certhash=$Hash appid=`{$Guid`} 

중요한 세부 사항이 탈출되어 백틱 (`) 각 {}.

은 netsh는 certstorename에게 추가 오류 87 시도를 제기하면 내

변수를 사용할 필요가 없습니다. 편의를 위해서입니다.

관련 문제