2016-11-23 93 views
1

檢測的最佳方式雖然等待the new certificate module,我們以下面的方式安裝證書:Ansible:如果一個證書已經安裝在證書存儲

win_shell: Import-PfxCertificate -filepath "{{ certificatePath }}" -certStorelocation cert:\\localmachine\\My -password $(ConvertTo-SecureString -AsPlainText -Force -String "{{ organization_key }}")

這工作得很好,但我沒有如果證書已經安裝,找到任何好方法來跳過任務。我知道你可以運行SET-LOCATION CERT:\LOCALMACHINE,它提供了作爲文件系統訪問證書存儲的權限,但是可以執行類似creates=cert:\localmachine\path\to\my\cert這樣的操作嗎?

這裏最好的策略是什麼?

回答

0

答案是很簡單: creates=Cert:\\LOCALMACHINE\\My\\{{ CertificateThumbprint }}

+0

請注意'\\「{{CertificateThumbrint}}」'需要轉義.. – amosti

0

Test-Path小命令還與證書提供商:

if (Test-Path cert:\localmachine\path\to\my\cert) 
{ 
}