メインコンテンツまでスキップ

How To Sign PowerShell Script Using Domain Trusted CA Certificate

User-added image

1. Make sure your HSM (.e.g, USB Token) containing the Code Signing certificate is plugged into your computer or laptop.

2. Open Windows PowerShell.

User-added image

3. To view all your Code Signing Certificates type the command below:

Get-ChildItem Cert:\CurrentUser\My –codesign

Note: You will see all your code signing certificates in an order that start from 0, 1, 2…

User-added image

4. Next, sign your script with the preferred Code Signing Certificate. If you have multiple Code Signing Certificates in the USB Hard Token based on the order of 0, 1, 2… as mentioned in Step 3, you may need to enter the password to access the token after running below cmdlet .

For this example, I have created a PowerShell script name “testscript.ps1” and I will used the Code Signing Certificate which is located on location [0] –

BB9373B96D226CAB1134E89535B590B681B8A37F  CN="Entrust, Inc.", O="Entrust, Inc.", L=Kanata, S=Ontario, C =CA”

Cmdlet to use:

Set-AuthenticodeSignature <script> @(Get-ChildItem Cert:\CurrentUser\My -CodeSign)<Location>
<script> - your PowerShell script
<Location> - Location of the Certificate in the format of [0] or [1] or [2] and so on

例:

Set-AuthenticodeSignature .\testscript.ps1 @(Get-ChildItem Cert:\CurrentUser\My -CodeSign)[0]
Make sure the Status is set to Valid after running the cmdlet.

User-added image

If you have any questions or concerns please contact the Entrust Certificate Services support department for further assistance.

Hours of Operation:
Sunday 8:00 PM ET to Friday 8:00 PM ET
North America (toll free): 1-866-267-9297
Outside North America: 1-613-270-2680 (or see the list below)
NOTE: It is very important that international callers dial the UITF format exactly as indicated. Do not dial an extra "1" before the "800" or your call will not be accepted as an UITF toll free call.

Number
オーストラリア 0011 - 800-3687-7863
1-800-767-513
オーストリア 00 - 800-3687-7863
ベルギー 00 - 800-3687-7863
デンマーク 00 - 800-3687-7863
フィンランド 990 - 800-3687-7863 (Telecom Finland)
00 - 800-3687-7863 (Finnet)
フランス 00 - 800-3687-7863
ドイツ 00 - 800-3687-7863
香港 001 - 800-3687-7863 (Voice)
002 - 800-3687-7863 (Fax)
アイルランド 00 - 800-3687-7863
イスラエル 014 - 800-3687-7863
イタリア 00 - 800-3687-7863
日本 001 - 800-3687-7863 (KDD)
004 - 800-3687-7863 (ITJ)
0061 - 800-3687-7863 (IDC)
Korea 001 - 800-3687-7863 (Korea Telecom)
002 - 800-3687-7863 (Dacom)
マレーシア 00 - 800-3687-7863
オランダ 00 - 800-3687-7863
ニュージーランド 00 - 800-3687-7863
0800-4413101
ノルウェー 00 - 800-3687-7863
シンガポール 001 - 800-3687-7863
スペイン 00 - 800-3687-7863
スウェーデン 00 - 800-3687-7863 (Telia)
00 - 800-3687-7863 (Tele2)
スイス 00 - 800-3687-7863
台湾 00 - 800-3687-7863
英国 00 - 800-3687-7863
0800 121 6078
+44 (0) 118 953 3088