Server : Apache/2.4.43 (Win64) OpenSSL/1.1.1g PHP/7.4.6 System : Windows NT USER-PC 6.1 build 7601 (Windows 7 Professional Edition Service Pack 1) AMD64 User : User ( 0) PHP Version : 7.4.6 Disable Function : NONE Directory : C:/Windows/SysWOW64/WindowsPowerShell/v1.0/zh-TW/ |
<?xml version="1.0" encoding="utf-8"?> <helpItems schema="maml"> <!-- v 1.1.0.9 --> <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10"> <command:details> <command:name> ConvertFrom-SecureString </command:name> <maml:description> <maml:para>將安全性字串轉換成標準加密字串。</maml:para> </maml:description> <maml:copyright> <maml:para></maml:para> </maml:copyright> <command:verb>ConvertFrom</command:verb> <command:noun>SecureString</command:noun> <dev:version></dev:version> </command:details> <maml:description> <maml:para>ConvertFrom-SecureString Cmdlet 會將安全字串 (System.Security.SecureString) 轉換成標準加密字串 (System.String)。與安全字串不同,標準加密字串可以儲存在檔案中,以便日後使用。您可以使用 ConvertTo-SecureString Cmdlet,將標準加密字串轉換回安全字串格式。如果使用 Key 或 SecureKey 參數指定加密金鑰,則會採用 Rijndael 加密演算法。指定金鑰的長度必須是 128、192 或 256 位元,因為這些是 Rijndael 加密演算法所支援的金鑰長度。如果沒有指定金鑰,則會使用 Windows 資料保護 API (DPAPI) 來加密標準字串表示。</maml:para> </maml:description> <!-- Cmdlet syntax section--> <command:syntax> <command:syntaxItem> <maml:name>ConvertFrom-SecureString</maml:name> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="false" position="named"> <maml:name>Key</maml:name> <maml:description> <maml:para>指定加密金鑰做為位元組陣列。</maml:para> </maml:description> <command:parameterValue required="true" variableLength="true">Byte[]</command:parameterValue> </command:parameter> <command:parameter required="true" variableLength="false" globbing="false" pipelineInput="true (ByValue)" position="1"> <maml:name>SecureString</maml:name> <maml:description> <maml:para>指定要轉換成標準加密字串的安全性字串。</maml:para> </maml:description> <command:parameterValue required="true" variableLength="false">SecureString</command:parameterValue> </command:parameter> </command:syntaxItem> <command:syntaxItem> <maml:name>ConvertFrom-SecureString</maml:name> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="2"> <maml:name>SecureKey</maml:name> <maml:description> <maml:para>指定加密金鑰做為安全性字串。安全性字串值會先轉換成位元組陣列再當作金鑰使用。</maml:para> </maml:description> <command:parameterValue required="true" variableLength="false">SecureString</command:parameterValue> </command:parameter> <command:parameter required="true" variableLength="false" globbing="false" pipelineInput="true (ByValue)" position="1"> <maml:name>SecureString</maml:name> <maml:description> <maml:para>指定要轉換成標準加密字串的安全性字串。</maml:para> </maml:description> <command:parameterValue required="true" variableLength="false">SecureString</command:parameterValue> </command:parameter> </command:syntaxItem> </command:syntax> <!-- Cmdlet parameter section --> <command:parameters> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="false" position="named"> <maml:name>Key</maml:name> <maml:description> <maml:para>指定加密金鑰做為位元組陣列。</maml:para> </maml:description> <command:parameterValue required="true" variableLength="true">Byte[]</command:parameterValue> <dev:type> <maml:name>Byte[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue></dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="2"> <maml:name>SecureKey</maml:name> <maml:description> <maml:para>指定加密金鑰做為安全性字串。安全性字串值會先轉換成位元組陣列再當作金鑰使用。</maml:para> </maml:description> <command:parameterValue required="true" variableLength="false">SecureString</command:parameterValue> <dev:type> <maml:name>SecureString</maml:name> <maml:uri /> </dev:type> <dev:defaultValue></dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="false" globbing="false" pipelineInput="true (ByValue)" position="1"> <maml:name>SecureString</maml:name> <maml:description> <maml:para>指定要轉換成標準加密字串的安全性字串。</maml:para> </maml:description> <command:parameterValue required="true" variableLength="false">SecureString</command:parameterValue> <dev:type> <maml:name>SecureString</maml:name> <maml:uri /> </dev:type> <dev:defaultValue></dev:defaultValue> </command:parameter> </command:parameters> <!-- Input - Output section--> <command:inputTypes> <command:inputType> <dev:type> <maml:name>System.Security.SecureString</maml:name> <maml:uri /> <maml:description /> </dev:type> <maml:description> <maml:para> <!-- description --> 您可經由管道將 SecureString 物件輸出至 ConvertFrom-SecureString。 </maml:para> </maml:description> </command:inputType> </command:inputTypes> <command:returnValues> <command:returnValue> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> <maml:description /> </dev:type> <maml:description> <maml:para> <!-- description --> ConvertFrom-SecureString 會傳回標準字串物件。 </maml:para> </maml:description> </command:returnValue> </command:returnValues> <!-- Error section--> <command:terminatingErrors /> <command:nonTerminatingErrors /> <!-- Notes section --> <maml:alertSet> <maml:title></maml:title> <maml:alert> <maml:para> 若要根據命令提示字元中輸入的字元建立安全字串,請使用 Read-Host Cmdlet 的 AsSecureString 參數。 當您使用 Key 或 SecureKey 參數指定金鑰時,金鑰長度必須是正確的。例如,可以將 128 位元的金鑰指定為 16 位數的位元組陣列。同樣地,192 位元和 256 位元金鑰會分別對應至 24 和 32 位數的位元組陣列。 </maml:para> </maml:alert> <maml:alert> <maml:para></maml:para> </maml:alert> </maml:alertSet> <!-- Example section --> <command:examples> <command:example> <maml:title> -------------------------- 範例 1 -------------------------- </maml:title> <maml:introduction> <maml:para>C:\PS></maml:para> </maml:introduction> <dev:code> $securestring = read-host -assecurestring </dev:code> <dev:remarks> <maml:para>描述</maml:para> <maml:para>-----------</maml:para> <maml:para>這個命令會根據您在命令提示字元中輸入的字元建立安全字串。輸入命令之後,請輸入您要儲存為安全性字串的字串。此時會顯示星號 (*) 來代表您輸入的每個字元。</maml:para> <maml:para></maml:para> <maml:para></maml:para> <maml:para></maml:para> <maml:para></maml:para> </dev:remarks> <command:commandLines> <command:commandLine> <command:commandText></command:commandText> </command:commandLine> </command:commandLines> </command:example> <command:example> <maml:title> -------------------------- 範例 2 -------------------------- </maml:title> <maml:introduction> <maml:para>C:\PS></maml:para> </maml:introduction> <dev:code> $standardstring = convertfrom-securestring $securestring </dev:code> <dev:remarks> <maml:para>描述</maml:para> <maml:para>-----------</maml:para> <maml:para>這個命令會將 $securestring 變數中的安全字串轉換成標準加密字串。產生的標準加密字串會儲存在 $standardstring 變數中。</maml:para> <maml:para></maml:para> <maml:para></maml:para> <maml:para></maml:para> <maml:para></maml:para> </dev:remarks> <command:commandLines> <command:commandLine> <command:commandText></command:commandText> </command:commandLine> </command:commandLines> </command:example> <command:example> <maml:title> -------------------------- 範例 3 -------------------------- </maml:title> <maml:introduction> <maml:para>C:\PS></maml:para> </maml:introduction> <dev:code> $key = (3,4,2,3,56,34,254,222,1,1,2,23,42,54,33,233,1,34,2,7,6,5,35,43) C:\PS> $standardstring = convertfrom-securestring $securestring -key $key </dev:code> <dev:remarks> <maml:para>描述</maml:para> <maml:para>-----------</maml:para> <maml:para>這些命令會使用 Rijndael 演算法,將 $securestring 變數中儲存的安全字串轉換成具有 192 位元金鑰的標準加密字串。產生的標準加密字串會儲存在 $standardstring 變數中。 第一個命令會將金鑰儲存在 $key 變數中。該金鑰是 24 位數的陣列,其中所有位數都小於 256。 因為每個位數都代表一個位元組 (8 位元),所以該金鑰的 24 位數總計為 192 位元 (8 x 24)。這是 Rijndael 演算法的有效金鑰長度。每個個別值都會小於 256,因為這是不帶正負號的位元組所能儲存的最大值。 第二個命令會使用 $key 變數中的金鑰,將安全字串轉換成標準加密字串。 </maml:para> <maml:para></maml:para> <maml:para></maml:para> <maml:para></maml:para> <maml:para></maml:para> </dev:remarks> <command:commandLines> <command:commandLine> <command:commandText></command:commandText> </command:commandLine> </command:commandLines> </command:example> </command:examples> <!-- Link section --> <maml:relatedLinks> <maml:navigationLink> <maml:linkText>Online version:</maml:linkText> <maml:uri>http://go.microsoft.com/fwlink/?LinkID=113287</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>ConvertTo-SecureString</maml:linkText> <maml:uri /> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Read-Host</maml:linkText> <maml:uri /> </maml:navigationLink> </maml:relatedLinks> </command:command> <!-- v 1.1.0.9 --> <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10"> <command:details> <command:name> ConvertTo-SecureString </command:name> <maml:description> <maml:para>將標準加密字串轉換為安全性字串。也可以將純文字轉換成安全性字串。這是搭配 ConvertFrom-SecureString 和 Read-Host 使用的。</maml:para> </maml:description> <maml:copyright> <maml:para></maml:para> </maml:copyright> <command:verb>ConvertTo</command:verb> <command:noun>SecureString</command:noun> <dev:version></dev:version> </command:details> <maml:description> <maml:para>ConvertTo-SecureString Cmdlet 會將標準加密字串轉換成安全字串。也可以將純文字轉換成安全性字串。這是搭配 ConvertFrom-SecureString 和 Read-Host 使用的。cmdlet 建立的安全性字串可以和需要 SecureString 類型參數的 cmdlet 或函數搭配使用。您可以使用 ConvertFrom-SecureString Cmdlet,將安全字串轉換回加密的標準字串。如此即可將它儲存在檔案中,以供日後使用。 如果即將轉換的標準字串是透過使用某個指定金鑰的 ConvertFrom-SecureString 所加密,則必須提供同一個金鑰做為 ConvertTo-SecureString Cmdlet 的 Key 或 SecureKey 參數值。</maml:para> </maml:description> <!-- Cmdlet syntax section--> <command:syntax> <command:syntaxItem> <maml:name>ConvertTo-SecureString</maml:name> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="false" position="named"> <maml:name>Key</maml:name> <maml:description> <maml:para>指定將安全性字串轉換成標準加密字串時所使用的加密金鑰。有效的金鑰長度為 16、24 和 32 位元組。</maml:para> </maml:description> <command:parameterValue required="true" variableLength="true">Byte[]</command:parameterValue> </command:parameter> <command:parameter required="true" variableLength="false" globbing="false" pipelineInput="true (ByValue)" position="1"> <maml:name>String</maml:name> <maml:description> <maml:para>指定要轉換成安全性字串的字串。</maml:para> </maml:description> <command:parameterValue required="true" variableLength="false">string</command:parameterValue> </command:parameter> </command:syntaxItem> <command:syntaxItem> <maml:name>ConvertTo-SecureString</maml:name> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="2"> <maml:name>AsPlainText</maml:name> <maml:description> <maml:para>指定要轉換成安全性字串的純文字字串。安全性字串 cmdlet 可協助保護機密文字。文字會經過加密以保障隱私,且使用後將從電腦記憶體刪除。若使用此參數提供純文字做為輸入,系統無法保護輸入的內容。使用此參數時,必須一併指定 Force 參數。</maml:para> </maml:description> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="3"> <maml:name>Force</maml:name> <maml:description> <maml:para>確認您已了解到使用 AsPlainText 參數的隱憂且仍想使用。</maml:para> </maml:description> </command:parameter> <command:parameter required="true" variableLength="false" globbing="false" pipelineInput="true (ByValue)" position="1"> <maml:name>String</maml:name> <maml:description> <maml:para>指定要轉換成安全性字串的字串。</maml:para> </maml:description> <command:parameterValue required="true" variableLength="false">string</command:parameterValue> </command:parameter> </command:syntaxItem> <command:syntaxItem> <maml:name>ConvertTo-SecureString</maml:name> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="2"> <maml:name>SecureKey</maml:name> <maml:description> <maml:para>指定將安全性字串轉換成標準加密字串時所使用的加密金鑰。提供的金鑰必須是安全性字串的格式。安全性字串會先轉換成位元組陣列再當作金鑰使用。有效的金鑰長度為 16、24 和 32 位元組。</maml:para> </maml:description> <command:parameterValue required="true" variableLength="false">SecureString</command:parameterValue> </command:parameter> <command:parameter required="true" variableLength="false" globbing="false" pipelineInput="true (ByValue)" position="1"> <maml:name>String</maml:name> <maml:description> <maml:para>指定要轉換成安全性字串的字串。</maml:para> </maml:description> <command:parameterValue required="true" variableLength="false">string</command:parameterValue> </command:parameter> </command:syntaxItem> </command:syntax> <!-- Cmdlet parameter section --> <command:parameters> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="2"> <maml:name>AsPlainText</maml:name> <maml:description> <maml:para>指定要轉換成安全性字串的純文字字串。安全性字串 cmdlet 可協助保護機密文字。文字會經過加密以保障隱私,且使用後將從電腦記憶體刪除。若使用此參數提供純文字做為輸入,系統無法保護輸入的內容。使用此參數時,必須一併指定 Force 參數。</maml:para> </maml:description> <command:parameterValue required="false" variableLength="false">SwitchParameter</command:parameterValue> <dev:type> <maml:name>SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue></dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="3"> <maml:name>Force</maml:name> <maml:description> <maml:para>確認您已了解到使用 AsPlainText 參數的隱憂且仍想使用。</maml:para> </maml:description> <command:parameterValue required="false" variableLength="false">SwitchParameter</command:parameterValue> <dev:type> <maml:name>SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue></dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="false" position="named"> <maml:name>Key</maml:name> <maml:description> <maml:para>指定將安全性字串轉換成標準加密字串時所使用的加密金鑰。有效的金鑰長度為 16、24 和 32 位元組。</maml:para> </maml:description> <command:parameterValue required="true" variableLength="true">Byte[]</command:parameterValue> <dev:type> <maml:name>Byte[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue></dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="2"> <maml:name>SecureKey</maml:name> <maml:description> <maml:para>指定將安全性字串轉換成標準加密字串時所使用的加密金鑰。提供的金鑰必須是安全性字串的格式。安全性字串會先轉換成位元組陣列再當作金鑰使用。有效的金鑰長度為 16、24 和 32 位元組。</maml:para> </maml:description> <command:parameterValue required="true" variableLength="false">SecureString</command:parameterValue> <dev:type> <maml:name>SecureString</maml:name> <maml:uri /> </dev:type> <dev:defaultValue></dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="false" globbing="false" pipelineInput="true (ByValue)" position="1"> <maml:name>String</maml:name> <maml:description> <maml:para>指定要轉換成安全性字串的字串。</maml:para> </maml:description> <command:parameterValue required="true" variableLength="false">string</command:parameterValue> <dev:type> <maml:name>string</maml:name> <maml:uri /> </dev:type> <dev:defaultValue></dev:defaultValue> </command:parameter> </command:parameters> <!-- Input - Output section--> <command:inputTypes> <command:inputType> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> <maml:description /> </dev:type> <maml:description> <maml:para> <!-- description --> 您可經由管道將標準加密字串輸出至 ConvertTo-SecureString。 </maml:para> </maml:description> </command:inputType> </command:inputTypes> <command:returnValues> <command:returnValue> <dev:type> <maml:name>System.Security.SecureString</maml:name> <maml:uri /> <maml:description /> </dev:type> <maml:description> <maml:para> <!-- description --> ConvertTo-SecureString 會傳回 SecureString 物件。 </maml:para> </maml:description> </command:returnValue> </command:returnValues> <!-- Error section--> <command:terminatingErrors /> <command:nonTerminatingErrors /> <!-- Notes section --> <maml:alertSet> <maml:title></maml:title> <maml:alert> <maml:para> </maml:para> </maml:alert> <maml:alert> <maml:para></maml:para> </maml:alert> </maml:alertSet> <!-- Example section --> <command:examples> <command:example> <maml:title> -------------------------- 範例 1 -------------------------- </maml:title> <maml:introduction> <maml:para>C:\PS></maml:para> </maml:introduction> <dev:code> $secure = read-host -assecurestring C:\PS> $secure System.Security.SecureString C:\PS> $encrypted = convertfrom-securestring -securestring $secure C:\PS> $encrypted 01000000d08c9ddf0115d1118c7a00c04fc297eb010000001a114d45b8dd3f4aa11ad7c0abdae9800000000002000000000003660000a8000000100000005df63cea84bfb7d70bd6842e7 efa79820000000004800000a000000010000000f10cd0f4a99a8d5814d94e0687d7430b100000008bf11f1960158405b2779613e9352c6d14000000e6b7bf46a9d485ff211b9b2a2df3bd 6eb67aae41 C:\PS> $secure2 = convertto-securestring -string $encrypted C:\PS> $secure2 System.Security.SecureString </dev:code> <dev:remarks> <maml:para>描述</maml:para> <maml:para>-----------</maml:para> <maml:para>這個範例會示範如何根據使用者輸入建立安全字串、將安全字串轉換成標準加密字串,然後將標準加密字串轉換回安全字串。 第一個命令會使用 Read-Host Cmdlet 的 AsSecureString 參數來建立安全字串。輸入此命令之後,您所輸入的任何字元都會轉換成安全字串,然後儲存在 $secure 變數中。 第二個命令會顯示 $secure 變數的內容。因為 $secure 變數包含安全字串,所以 Windows PowerShell 只會顯示 System.Security.SecureString 型別。 第三個命令會使用 ConvertFrom-SecureString Cmdlet,將 $secure 變數中的安全字串轉換成標準加密字串。然後,它會將結果儲存在 $encrypted 變數中。第四個命令會顯示 $encrypted 變數值中的加密字串。 第五個命令會使用 ConvertTo-SecureString Cmdlet,將 $encrypted 變數中的標準加密字串轉換回安全字串。然後,它會將結果儲存在 $secure2 變數中。第六個命令會顯示 $secure2 變數的值。SecureString 型別表示命令執行成功。</maml:para> <maml:para></maml:para> <maml:para></maml:para> <maml:para></maml:para> <maml:para></maml:para> </dev:remarks> <command:commandLines> <command:commandLine> <command:commandText></command:commandText> </command:commandLine> </command:commandLines> </command:example> <command:example> <maml:title> -------------------------- 範例 2 -------------------------- </maml:title> <maml:introduction> <maml:para>C:\PS></maml:para> </maml:introduction> <dev:code> $secure = read-host -assecurestring C:\PS> $encrypted = convertfrom-securestring -secureString $secure -key (1..16) C:\PS> $encrypted | set-content encrypted.txt C:\PS> $secure2 = get-content encrypted.txt | convertto-securestring -key (1..16) </dev:code> <dev:remarks> <maml:para>描述</maml:para> <maml:para>-----------</maml:para> <maml:para>這個範例會示範如何根據儲存在檔案中的標準加密字串建立安全字串。 第一個命令會使用 Read-Host Cmdlet 的 AsSecureString 參數來建立安全字串。輸入此命令之後,您所輸入的任何字元都會轉換成安全字串,然後儲存在 $secure 變數中。 第二個命令會使用 ConvertFrom-SecureString Cmdlet,利用指定的金鑰將 $secure 變數中的安全字串轉換成標準加密字串。然後,這些內容會儲存在 $encrypted 變數中。 第三個命令會使用管線運算子 (|),將 $encrypted 變數的值傳送至 Set-Content Cmdlet,以便在 Encrypted.txt 檔案中儲存該值。 第四個命令會使用 Get-Content Cmdlet 來取得 Encrypted.txt 檔案中的標準加密字串。此命令會使用管線運算子,將加密字串傳送至 ConvertTo-SecureString Cmdlet,以便使用指定的金鑰將它轉換成安全字串。然後,這些結果會儲存在 $secure2 變數中。</maml:para> <maml:para></maml:para> <maml:para></maml:para> <maml:para></maml:para> <maml:para></maml:para> </dev:remarks> <command:commandLines> <command:commandLine> <command:commandText></command:commandText> </command:commandLine> </command:commandLines> </command:example> <command:example> <maml:title> -------------------------- 範例 3 -------------------------- </maml:title> <maml:introduction> <maml:para>C:\PS></maml:para> </maml:introduction> <dev:code> $secure_string_pwd = convertto-securestring "P@ssW0rD!" -asplaintext -force </dev:code> <dev:remarks> <maml:para>描述</maml:para> <maml:para>-----------</maml:para> <maml:para>這個命令會將純文字字串 "P@ssW0rD!" 轉換成安全字串,並將結果儲存在 $secure_string_pwd 變數中。若要使用 AsPlainText 參數,此命令也必須包含 Force 參數。</maml:para> <maml:para></maml:para> <maml:para></maml:para> <maml:para></maml:para> <maml:para></maml:para> </dev:remarks> <command:commandLines> <command:commandLine> <command:commandText></command:commandText> </command:commandLine> </command:commandLines> </command:example> </command:examples> <!-- Link section --> <maml:relatedLinks> <maml:navigationLink> <maml:linkText>Online version:</maml:linkText> <maml:uri>http://go.microsoft.com/fwlink/?LinkID=113291</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>ConvertFrom-SecureString</maml:linkText> <maml:uri /> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Read-Host</maml:linkText> <maml:uri /> </maml:navigationLink> </maml:relatedLinks> </command:command> <!-- v 1.1.0.9 --> <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10"> <command:details> <command:name> Get-Acl </command:name> <maml:description> <maml:para>取得資源 (如檔案或登錄機碼) 的安全性描述元。</maml:para> </maml:description> <maml:copyright> <maml:para></maml:para> </maml:copyright> <command:verb>Get</command:verb> <command:noun>Acl</command:noun> <dev:version></dev:version> </command:details> <maml:description> <maml:para>Get-Acl Cmdlet 會取得代表檔案或資源之安全性描述元的物件。安全性描述元包含資源的存取控制清單 (ACL)。ACL 會指定使用者及使用者群組存取資源所需的權限。</maml:para> </maml:description> <!-- Cmdlet syntax section--> <command:syntax> <command:syntaxItem> <maml:name>Get-Acl</maml:name> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="true (ByValue, ByPropertyName)" position="1"> <maml:name>Path</maml:name> <maml:description> <maml:para>指定資源的路徑。Get-Acl 會取得路徑所指定資源的安全性描述元。允許使用萬用字元。如果省略 Path 參數,Get-Acl 將取得目前目錄的安全性描述元。 參數名稱 ("Path") 為選擇項。</maml:para> </maml:description> <command:parameterValue required="true" variableLength="true">string[]</command:parameterValue> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named"> <maml:name>Audit</maml:name> <maml:description> <maml:para>從系統存取控制名單 (SACL) 取得安全性描述元的稽核資料。</maml:para> </maml:description> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="false" position="named"> <maml:name>Exclude</maml:name> <maml:description> <maml:para>忽略指定的項目。此參數的值用於限定 Path 參數。輸入路徑元素或模式,例如 "*.txt"。允許使用萬用字元。</maml:para> </maml:description> <command:parameterValue required="true" variableLength="true">string[]</command:parameterValue> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named"> <maml:name>Filter</maml:name> <maml:description> <maml:para>指定以提供者的格式或語言表示的篩選器。此參數的值用於限定 Path 參數。篩選器的語法 (包括萬用字元的用法) 依提供者而定。篩選器比其他參數更有效率,因為提供者會在擷取物件時套用篩選器,而非等到 Windows PowerShell 擷取物件後才進行篩選。</maml:para> </maml:description> <command:parameterValue required="true" variableLength="false">string</command:parameterValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="false" position="named"> <maml:name>Include</maml:name> <maml:description> <maml:para>只擷取指定的項目。此參數的值用於限定 Path 參數。輸入路徑元素或模式,例如 "*.txt"。允許使用萬用字元。</maml:para> </maml:description> <command:parameterValue required="true" variableLength="true">string[]</command:parameterValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="false" position="named"> <maml:name>UseTransaction</maml:name> <maml:description> <maml:para>將命令加入現用交易中。此參數只有當交易進行中時才有效。如需詳細資訊,請參閱 about_Transactions。</maml:para> </maml:description> </command:parameter> </command:syntaxItem> </command:syntax> <!-- Cmdlet parameter section --> <command:parameters> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named"> <maml:name>Audit</maml:name> <maml:description> <maml:para>從系統存取控制名單 (SACL) 取得安全性描述元的稽核資料。</maml:para> </maml:description> <command:parameterValue required="false" variableLength="false">SwitchParameter</command:parameterValue> <dev:type> <maml:name>SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue></dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="false" position="named"> <maml:name>Exclude</maml:name> <maml:description> <maml:para>忽略指定的項目。此參數的值用於限定 Path 參數。輸入路徑元素或模式,例如 "*.txt"。允許使用萬用字元。</maml:para> </maml:description> <command:parameterValue required="true" variableLength="true">string[]</command:parameterValue> <dev:type> <maml:name>string[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue></dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named"> <maml:name>Filter</maml:name> <maml:description> <maml:para>指定以提供者的格式或語言表示的篩選器。此參數的值用於限定 Path 參數。篩選器的語法 (包括萬用字元的用法) 依提供者而定。篩選器比其他參數更有效率,因為提供者會在擷取物件時套用篩選器,而非等到 Windows PowerShell 擷取物件後才進行篩選。</maml:para> </maml:description> <command:parameterValue required="true" variableLength="false">string</command:parameterValue> <dev:type> <maml:name>string</maml:name> <maml:uri /> </dev:type> <dev:defaultValue></dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="false" position="named"> <maml:name>Include</maml:name> <maml:description> <maml:para>只擷取指定的項目。此參數的值用於限定 Path 參數。輸入路徑元素或模式,例如 "*.txt"。允許使用萬用字元。</maml:para> </maml:description> <command:parameterValue required="true" variableLength="true">string[]</command:parameterValue> <dev:type> <maml:name>string[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue></dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="true (ByValue, ByPropertyName)" position="1"> <maml:name>Path</maml:name> <maml:description> <maml:para>指定資源的路徑。Get-Acl 會取得路徑所指定資源的安全性描述元。允許使用萬用字元。如果省略 Path 參數,Get-Acl 將取得目前目錄的安全性描述元。 參數名稱 ("Path") 為選擇項。</maml:para> </maml:description> <command:parameterValue required="true" variableLength="true">string[]</command:parameterValue> <dev:type> <maml:name>string[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue></dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="false" position="named"> <maml:name>UseTransaction</maml:name> <maml:description> <maml:para>將命令加入現用交易中。此參數只有當交易進行中時才有效。如需詳細資訊,請參閱 about_Transactions。</maml:para> </maml:description> <command:parameterValue required="false" variableLength="false">SwitchParameter</command:parameterValue> <dev:type> <maml:name>SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue /> </command:parameter> </command:parameters> <!-- Input - Output section--> <command:inputTypes> <command:inputType> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> <maml:description /> </dev:type> <maml:description> <maml:para> <!-- description --> 您可經由管道將包含路徑的字串輸出至 Get-Acl。 </maml:para> </maml:description> </command:inputType> </command:inputTypes> <command:returnValues> <command:returnValue> <dev:type> <maml:name>System.Security.AccessControl</maml:name> <maml:uri /> <maml:description /> </dev:type> <maml:description> <maml:para> <!-- description --> Get-Acl 會傳回代表它所取得之 ACL 的物件。此物件類型取決於 ACL 類型。 </maml:para> </maml:description> </command:returnValue> </command:returnValues> <!-- Error section--> <command:terminatingErrors /> <command:nonTerminatingErrors /> <!-- Notes section --> <maml:alertSet> <maml:title></maml:title> <maml:alert> <maml:para> 根據預設,Get-Acl 會顯示資源的 Windows PowerShell 路徑 (<提供者>::<資源路徑>)、資源的擁有者以及「存取」(資源之判別存取控制清單 (DACL) 中的存取控制項目清單 (陣列))。DACL 清單是由資源擁有者控制。 當您將結果格式化成清單時 ("get-acl | format-list"),除了路徑、擁有者和存取清單之外,Windows PowerShell 還會顯示下列欄位: -- 群組:擁有者的安全性群組。 -- 稽核:系統存取控制名單 (SACL) 中的項目清單 (陣列)。SACL 指定 Windows 產生稽核記錄時所針對的存取嘗試類型。 -- Sddl:以安全性描述元定義語言格式的單一文字字串顯示的資源安全性描述元。Windows PowerShell 使用安全性描述元的 GetSddlForm 方法來擷取這個資料。 因為檔案系統和登錄提供者支援 Get-Acl,所以您可以使用 Get-Acl 來檢視檔案系統物件 (如檔案及目錄) 與登錄物件 (如登錄機碼及項目) 的 ACL。 </maml:para> </maml:alert> <maml:alert> <maml:para></maml:para> </maml:alert> </maml:alertSet> <!-- Example section --> <command:examples> <command:example> <maml:title> -------------------------- 範例 1 -------------------------- </maml:title> <maml:introduction> <maml:para>C:\PS></maml:para> </maml:introduction> <dev:code> get-acl C:\windows </dev:code> <dev:remarks> <maml:para>描述</maml:para> <maml:para>-----------</maml:para> <maml:para>這個命令會取得 C:Windows 目錄的安全性描述元。</maml:para> <maml:para></maml:para> <maml:para></maml:para> <maml:para></maml:para> <maml:para></maml:para> </dev:remarks> <command:commandLines> <command:commandLine> <command:commandText></command:commandText> </command:commandLine> </command:commandLines> </command:example> <command:example> <maml:title> -------------------------- 範例 2 -------------------------- </maml:title> <maml:introduction> <maml:para>C:\PS></maml:para> </maml:introduction> <dev:code> get-acl C:\Windows\k*.log | format-list -property PSPath, Sddl </dev:code> <dev:remarks> <maml:para>描述</maml:para> <maml:para>-----------</maml:para> <maml:para>這個命令取得 C:\windows 目錄中,其名稱以 "k" 開頭之所有 .log 檔案的 Windows PowerShell 路徑與 SDDL。 此命令會使用 Get-Acl 來取得代表每個記錄檔安全性描述元的物件。它使用管線運算子 (|) 傳送結果給 Format-List Cmdlet。此命令會使用 Format-List 的 Property 參數來單獨顯示每個安全性描述元物件的 PsPath 和 SDDL 屬性。 Windows PowerShell 經常使用清單,因為較長的值顯示在表格中會被截斷。 SDDL 值對系統管理員而言非常有用,因為這是包含安全性描述元中所有資訊的簡單文字字串。因此,這些值很容易傳遞與儲存,而且還可在需要時加以剖析。</maml:para> <maml:para></maml:para> <maml:para></maml:para> <maml:para></maml:para> <maml:para></maml:para> </dev:remarks> <command:commandLines> <command:commandLine> <command:commandText></command:commandText> </command:commandLine> </command:commandLines> </command:example> <command:example> <maml:title> -------------------------- 範例 3 -------------------------- </maml:title> <maml:introduction> <maml:para>C:\PS></maml:para> </maml:introduction> <dev:code> get-ACL c:/windows/k*.log -Audit | foreach-object { $_.Audit.Count } </dev:code> <dev:remarks> <maml:para>描述</maml:para> <maml:para>-----------</maml:para> <maml:para>這個命令會取得 C:\Windows 目錄中,其名稱以 "k" 開頭之所有 .log 檔案的安全性描述元。它會使用 Audit 參數,從安全性描述的 SACL 中擷取稽核記錄。然後使用 For-EachObject 參數來計算每個檔案的相關稽核記錄的筆數。所得結果會是一份代表每個記錄檔稽核記錄筆數的數目清單。</maml:para> <maml:para></maml:para> <maml:para></maml:para> <maml:para></maml:para> <maml:para></maml:para> </dev:remarks> <command:commandLines> <command:commandLine> <command:commandText></command:commandText> </command:commandLine> </command:commandLines> </command:example> <command:example> <maml:title> -------------------------- 範例 4 -------------------------- </maml:title> <maml:introduction> <maml:para>C:\PS></maml:para> </maml:introduction> <dev:code> get-acl -path hklm:\system\currentcontrolset\control | format-list </dev:code> <dev:remarks> <maml:para>描述</maml:para> <maml:para>-----------</maml:para> <maml:para>這個命令會使用 Get-Acl 來取得登錄之 Control 子機碼 (HKLM\SYSTEM\CurrentControlSet\Control) 的安全性描述元。 Path 參數會指定 Control 子機碼。管線運算子 (|) 會將 Get-Acl 所擷取的安全性描述元傳遞給 Format-List 命令,後者再將安全性描述元的屬性格式化為清單,以便於閱讀。</maml:para> <maml:para></maml:para> <maml:para></maml:para> <maml:para></maml:para> <maml:para></maml:para> </dev:remarks> <command:commandLines> <command:commandLine> <command:commandText></command:commandText> </command:commandLine> </command:commandLines> </command:example> </command:examples> <!-- Link section --> <maml:relatedLinks> <maml:navigationLink> <maml:linkText>Online version:</maml:linkText> <maml:uri>http://go.microsoft.com/fwlink/?LinkID=113305</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Set-Acl</maml:linkText> <maml:uri /> </maml:navigationLink> </maml:relatedLinks> </command:command> <!-- v 1.1.0.9 --> <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10"> <command:details> <command:name> Get-AuthenticodeSignature </command:name> <maml:description> <maml:para>取得檔案中 Authenticode 簽章的相關資訊。</maml:para> </maml:description> <maml:copyright> <maml:para></maml:para> </maml:copyright> <command:verb>Get</command:verb> <command:noun>AuthenticodeSignature</command:noun> <dev:version></dev:version> </command:details> <maml:description> <maml:para>Get-AuthenticodeSignature Cmdlet 會取得檔案中 Authenticode 簽章的相關資訊。如果檔案未經簽署,仍會擷取資訊,但是其欄位為空白。</maml:para> </maml:description> <!-- Cmdlet syntax section--> <command:syntax> <command:syntaxItem> <maml:name>Get-AuthenticodeSignature</maml:name> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="true (ByValue, ByPropertyName)" position="1"> <maml:name>FilePath</maml:name> <maml:description> <maml:para>指定要檢查之檔案的路徑。允許使用萬用字元,但解析結果必須是單一檔案。參數名稱 ("FilePath") 為選擇項。</maml:para> </maml:description> <command:parameterValue required="true" variableLength="true">string[]</command:parameterValue> </command:parameter> </command:syntaxItem> </command:syntax> <!-- Cmdlet parameter section --> <command:parameters> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="true (ByValue, ByPropertyName)" position="1"> <maml:name>FilePath</maml:name> <maml:description> <maml:para>指定要檢查之檔案的路徑。允許使用萬用字元,但解析結果必須是單一檔案。參數名稱 ("FilePath") 為選擇項。</maml:para> </maml:description> <command:parameterValue required="true" variableLength="true">string[]</command:parameterValue> <dev:type> <maml:name>string[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue></dev:defaultValue> </command:parameter> </command:parameters> <!-- Input - Output section--> <command:inputTypes> <command:inputType> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> <maml:description /> </dev:type> <maml:description> <maml:para> <!-- description --> 您可經由管道將包含檔案路徑的字串輸出至 Get-AuthenticodeSignature。 </maml:para> </maml:description> </command:inputType> </command:inputTypes> <command:returnValues> <command:returnValue> <dev:type> <maml:name>System.Management.Automation.Signature</maml:name> <maml:uri /> <maml:description /> </dev:type> <maml:description> <maml:para> <!-- description --> Get-AuthenticodeSignature 會針對它所取得的每個簽章傳回一個簽章物件。 </maml:para> </maml:description> </command:returnValue> </command:returnValues> <!-- Error section--> <command:terminatingErrors /> <command:nonTerminatingErrors /> <!-- Notes section --> <maml:alertSet> <maml:title></maml:title> <maml:alert> <maml:para> 如需 Windows PowerShell 中 Authenticode 簽章的詳細資訊,請參閱 about_Signing。 </maml:para> </maml:alert> <maml:alert> <maml:para></maml:para> </maml:alert> </maml:alertSet> <!-- Example section --> <command:examples> <command:example> <maml:title> -------------------------- 範例 1 -------------------------- </maml:title> <maml:introduction> <maml:para>C:\PS></maml:para> </maml:introduction> <dev:code> get-AuthenticodeSignature -filepath C:\Test\NewScript.ps1 </dev:code> <dev:remarks> <maml:para>描述</maml:para> <maml:para>-----------</maml:para> <maml:para>這個命令會在 NewScript.ps1 檔案中取得 Authenticode 簽章的相關資訊。它會使用 FilePath 參數來指定檔案。</maml:para> <maml:para></maml:para> <maml:para></maml:para> <maml:para></maml:para> <maml:para></maml:para> </dev:remarks> <command:commandLines> <command:commandLine> <command:commandText></command:commandText> </command:commandLine> </command:commandLines> </command:example> <command:example> <maml:title> -------------------------- 範例 2 -------------------------- </maml:title> <maml:introduction> <maml:para>C:\PS></maml:para> </maml:introduction> <dev:code> get-authenticodesignature test.ps1, test1.ps1, sign-file.ps1, makexml.ps1 </dev:code> <dev:remarks> <maml:para>描述</maml:para> <maml:para>-----------</maml:para> <maml:para>這個命令會在命令列所列出的四個檔案中取得 Authenticode 簽章的相關資訊。在此命令中,省略了選擇性的 FilePath 參數名稱。</maml:para> <maml:para></maml:para> <maml:para></maml:para> <maml:para></maml:para> <maml:para></maml:para> </dev:remarks> <command:commandLines> <command:commandLine> <command:commandText></command:commandText> </command:commandLine> </command:commandLines> </command:example> <command:example> <maml:title> -------------------------- 範例 3 -------------------------- </maml:title> <maml:introduction> <maml:para>C:\PS></maml:para> </maml:introduction> <dev:code> get-childitem $pshome\*.* | foreach-object {Get-AuthenticodeSignature $_} | where {$_.status -eq "Valid"} </dev:code> <dev:remarks> <maml:para>描述</maml:para> <maml:para>-----------</maml:para> <maml:para>這個命令會列出 $pshome 目錄中具有有效 Authenticode 簽章的所有檔案。$pshome 自動變數包含 Windows PowerShell 安裝目錄的路徑。 此命令使用 Get-ChildItem Cmdlet 取得 $pshome 目錄中的檔案。它會使用 *.* 模式來排除目錄 (雖然它也會排除檔名中沒有點的檔案)。 此命令使用管線運算子 (|),將 $pshome 中的檔案傳送給 Foreach-Object Cmdlet,後者會針對每個檔案呼叫 Get-AuthenticodeSignature。 Get-AuthenticodeSignature Command 的結果會傳送給 Where-Object 命令,後者只會選取具有「有效」狀態的簽章物件。</maml:para> <maml:para></maml:para> <maml:para></maml:para> <maml:para></maml:para> <maml:para></maml:para> </dev:remarks> <command:commandLines> <command:commandLine> <command:commandText></command:commandText> </command:commandLine> </command:commandLines> </command:example> </command:examples> <!-- Link section --> <maml:relatedLinks> <maml:navigationLink> <maml:linkText>Online version:</maml:linkText> <maml:uri>http://go.microsoft.com/fwlink/?LinkID=113307</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>about_Signing</maml:linkText> <maml:uri /> </maml:navigationLink> <maml:navigationLink> <maml:linkText>about_Execution_Policies</maml:linkText> <maml:uri /> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Set-AuthenticodeSignature</maml:linkText> <maml:uri /> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Get-ExecutionPolicy</maml:linkText> <maml:uri /> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Set-ExecutionPolicy</maml:linkText> <maml:uri /> </maml:navigationLink> </maml:relatedLinks> </command:command> <!-- v 1.1.0.9 --> <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10"> <command:details> <command:name> Get-Credential </command:name> <maml:description> <maml:para>根據使用者名稱和密碼取得認證物件。</maml:para> </maml:description> <maml:copyright> <maml:para></maml:para> </maml:copyright> <command:verb>Get</command:verb> <command:noun>Credential</command:noun> <dev:version></dev:version> </command:details> <maml:description> <maml:para>Get-Credential Cmdlet 會為指定的使用者名稱和密碼建立認證物件。您可以在安全性操作中使用認證物件。 此 Cmdlet 會提示使用者輸入密碼或者使用者名稱和密碼。系統會透過對話方塊或命令列提示使用者,根據系統登錄設定而定。</maml:para> </maml:description> <!-- Cmdlet syntax section--> <command:syntax> <command:syntaxItem> <maml:name>Get-Credential</maml:name> <command:parameter required="true" variableLength="false" globbing="false" pipelineInput="false" position="1"> <maml:name>Credential</maml:name> <maml:description> <maml:para>指定認證的使用者名稱,例如 "User01" 或 "Domain01\User01"。參數名稱 ("Credential") 為選擇項。 當您提交命令時,系統將提示您提供密碼。 如果您輸入沒有網域的使用者名稱,Get-Credential 會在名稱之前插入反斜線。 如果省略此參數,則會提示您提供使用者名稱和密碼。</maml:para> </maml:description> <command:parameterValue required="true" variableLength="false">PSCredential</command:parameterValue> </command:parameter> </command:syntaxItem> </command:syntax> <!-- Cmdlet parameter section --> <command:parameters> <command:parameter required="true" variableLength="false" globbing="false" pipelineInput="false" position="1"> <maml:name>Credential</maml:name> <maml:description> <maml:para>指定認證的使用者名稱,例如 "User01" 或 "Domain01\User01"。參數名稱 ("Credential") 為選擇項。 當您提交命令時,系統將提示您提供密碼。 如果您輸入沒有網域的使用者名稱,Get-Credential 會在名稱之前插入反斜線。 如果省略此參數,則會提示您提供使用者名稱和密碼。</maml:para> </maml:description> <command:parameterValue required="true" variableLength="false">PSCredential</command:parameterValue> <dev:type> <maml:name>PSCredential</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>無</dev:defaultValue> </command:parameter> </command:parameters> <!-- Input - Output section--> <command:inputTypes> <command:inputType> <dev:type> <maml:name>無</maml:name> <maml:uri /> <maml:description /> </dev:type> <maml:description> <maml:para> <!-- description --> 您無法經由管道將輸入輸出至這個 Cmdlet。 </maml:para> </maml:description> </command:inputType> </command:inputTypes> <command:returnValues> <command:returnValue> <dev:type> <maml:name>System.Management.Automation.PSCredential</maml:name> <maml:uri /> <maml:description /> </dev:type> <maml:description> <maml:para> <!-- description --> Get-Credential 會傳回認證物件。 </maml:para> </maml:description> </command:returnValue> </command:returnValues> <!-- Error section--> <command:terminatingErrors /> <command:nonTerminatingErrors /> <!-- Notes section --> <maml:alertSet> <maml:title></maml:title> <maml:alert> <maml:para> 您可以在要求使用者驗證的 Cmdlet (例如使用 Credential 參數的 Cmdlet) 中使用 Get-Credential 所建立的 PSCredential 物件。 與 Windows PowerShell 一起安裝的提供者並不支援 Credential 參數。不過,您可以使用 Credential 參數搭配 Get-WmiObject,因為它會直接呼叫 Microsoft .NET Framework。 </maml:para> </maml:alert> <maml:alert> <maml:para></maml:para> </maml:alert> </maml:alertSet> <!-- Example section --> <command:examples> <command:example> <maml:title> -------------------------- 範例 1 -------------------------- </maml:title> <maml:introduction> <maml:para>C:\PS></maml:para> </maml:introduction> <dev:code> $c = Get-Credential </dev:code> <dev:remarks> <maml:para>描述</maml:para> <maml:para>-----------</maml:para> <maml:para>這個命令會取得認證物件,並將它儲存在 $c 變數中。 輸入此命令時,會出現對話方塊要求使用者名稱和密碼。輸入所要求的資訊後,此 cmdlet 會建立代表使用者認證的 PSCredential 物件,並將它儲存在 $c 變數中。 您可以使用該物件做為要求使用者驗證之 cmdlet (例如那些使用 Credential 參數的 cmdlet) 的輸入。不過,與 Windows PowerShell 一起安裝的提供者並不支援 Credential 參數。</maml:para> <maml:para></maml:para> <maml:para></maml:para> <maml:para></maml:para> <maml:para></maml:para> </dev:remarks> <command:commandLines> <command:commandLine> <command:commandText></command:commandText> </command:commandLine> </command:commandLines> </command:example> <command:example> <maml:title> -------------------------- 範例 2 -------------------------- </maml:title> <maml:introduction> <maml:para>C:\PS></maml:para> </maml:introduction> <dev:code> $c = Get-Credential C:\PS>Get-WmiObject Win32_DiskDrive -ComputerName Server01 -Credential $c </dev:code> <dev:remarks> <maml:para>描述</maml:para> <maml:para>-----------</maml:para> <maml:para>這些命令會使用來自 Get-Credential 的認證物件,以驗證遠端電腦上的使用者,讓他們可以使用 Windows Management Instrumentation (WMI) 來管理電腦。 第一個命令取得認證物件,並將它儲存在 $c 變數中。第二個命令會在 Get-WmiObject 命令中使用認證物件。這個命令會取得 Server01 電腦上磁碟機的相關資訊。</maml:para> <maml:para></maml:para> <maml:para></maml:para> <maml:para></maml:para> <maml:para></maml:para> </dev:remarks> <command:commandLines> <command:commandLine> <command:commandText></command:commandText> </command:commandLine> </command:commandLines> </command:example> <command:example> <maml:title> -------------------------- 範例 3 -------------------------- </maml:title> <maml:introduction> <maml:para>C:\PS></maml:para> </maml:introduction> <dev:code> C:\PS>Get-WmiObject Win32_BIOS -ComputerName Server01 ' -Credential (get-credential Domain01\User01) </dev:code> <dev:remarks> <maml:para>描述</maml:para> <maml:para>-----------</maml:para> <maml:para>這個命令會示範如何在 Get-WmiObject 命令中加入 Get-Credential 命令。 這個命令會使用 Get-WmiObject Cmdlet 來取得 Server01 電腦上 BIOS 的相關資訊。它會使用 Credential 參數來驗證使用者 Domain01\User01,並使用 Get-Credential 命令當作 Credential 參數的值。</maml:para> <maml:para></maml:para> <maml:para></maml:para> <maml:para></maml:para> <maml:para></maml:para> </dev:remarks> <command:commandLines> <command:commandLine> <command:commandText></command:commandText> </command:commandLine> </command:commandLines> </command:example> <command:example> <maml:title> -------------------------- 範例 4 -------------------------- </maml:title> <maml:introduction> <maml:para>C:\PS></maml:para> </maml:introduction> <dev:code> $c = Get-Credential -credential User01 C:\PS>$c.Username \User01 </dev:code> <dev:remarks> <maml:para>描述</maml:para> <maml:para>-----------</maml:para> <maml:para>這個範例會建立認證,其中包含使用者名稱,但沒有網域名稱。此範例示範 Get-Credential 會在使用者名稱之前插入反斜線。 第一個命令會取得使用者名稱 User01 的認證並將它儲存在 $c 變數中。 第二個命令則顯示所產生之認證物件的 Username 屬性值。</maml:para> <maml:para></maml:para> <maml:para></maml:para> <maml:para></maml:para> <maml:para></maml:para> </dev:remarks> <command:commandLines> <command:commandLine> <command:commandText></command:commandText> </command:commandLine> </command:commandLines> </command:example> <command:example> <maml:title> -------------------------- 範例 5 -------------------------- </maml:title> <maml:introduction> <maml:para>C:\PS></maml:para> </maml:introduction> <dev:code> $credential = $host.ui.PromptForCredential("Need credentials", "Please enter your user name and password.", "", "NetBiosUserName") </dev:code> <dev:remarks> <maml:para>描述</maml:para> <maml:para>-----------</maml:para> <maml:para>此命令使用 PromptForCredential 方法提示使用者輸入使用者名稱和密碼。此命令將產生的認證儲存在 $credential 變數中。 PromptForCredential 是除了使用 Get-Credential 以外的另一項選擇。當您使用 PromptForCredential 時,可以指定出現在訊息方塊上的標題、訊息和使用者名稱。</maml:para> <maml:para></maml:para> <maml:para></maml:para> <maml:para></maml:para> <maml:para></maml:para> </dev:remarks> <command:commandLines> <command:commandLine> <command:commandText></command:commandText> </command:commandLine> </command:commandLines> </command:example> <command:example> <maml:title> -------------------------- 範例 6 -------------------------- </maml:title> <maml:introduction> <maml:para>C:\PS></maml:para> </maml:introduction> <dev:code> Set-ItemProperty 'HKLM:\SOFTWARE\Microsoft\PowerShell\1\ShellIds' ConsolePrompting $true </dev:code> <dev:remarks> <maml:para>描述</maml:para> <maml:para>-----------</maml:para> <maml:para>當需要使用者名稱和密碼時,會出現對話方塊來提示使用者輸入。若要以命令列進行提示,請在 Windows PowerShell 中以 [以系統管理員身分執行] 執行此命令來修改登錄。 若要以對話方塊進行提示,請使用相同的命令搭配 "ConsolePrompting $false"。 </maml:para> <maml:para></maml:para> <maml:para></maml:para> <maml:para></maml:para> <maml:para></maml:para> </dev:remarks> <command:commandLines> <command:commandLine> <command:commandText></command:commandText> </command:commandLine> </command:commandLines> </command:example> </command:examples> <!-- Link section --> <maml:relatedLinks> <maml:navigationLink> <maml:linkText>Online version:</maml:linkText> <maml:uri>http://go.microsoft.com/fwlink/?LinkID=113311</maml:uri> </maml:navigationLink> </maml:relatedLinks> </command:command> <!-- v 1.1.0.9 --> <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10"> <command:details> <command:name> Get-ExecutionPolicy </command:name> <maml:description> <maml:para>取得目前工作階段的執行原則。</maml:para> </maml:description> <maml:copyright> <maml:para></maml:para> </maml:copyright> <command:verb>Get</command:verb> <command:noun>ExecutionPolicy</command:noun> <dev:version></dev:version> </command:details> <maml:description> <maml:para>Get-ExecutionPolicy Cmdlet 會取得目前工作階段的執行原則。 執行原則是由您使用 Set-ExecutionPolicy 所設定的執行原則以及 Windows PowerShell 執行原則的群組原則設定來決定。預設值為 "Restricted"。 如果沒有參數,Get-ExecutionPolicy 就會取得工作階段中的有效執行原則。您可以使用 List 參數來取得影響工作階段的所有執行原則,或使用 Scope 參數來取得特定範圍的執行原則。 如需詳細資訊,請參閱 about_Execution_Policies。</maml:para> </maml:description> <!-- Cmdlet syntax section--> <command:syntax> <command:syntaxItem> <maml:name>Get-ExecutionPolicy</maml:name> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="true (ByPropertyName)" position="1"> <maml:name>Scope</maml:name> <maml:description> <maml:para>取得指定之範圍中的執行原則。根據預設,Get-ExecutionPolicy 會取得目前工作階段的有效執行原則。 有效的值包括: -- MachinePolicy:所有電腦使用者之群組原則所設定的執行原則。 -- UserPolicy:目前電腦使用者之群組原則所設定的執行原則。 -- Process:針對目前 Windows PowerShell 處理序所設定的執行原則。 -- CurrentUser:針對目前使用者所設定的執行原則。 -- LocalMachine:針對所有電腦使用者所設定的執行原則。</maml:para> </maml:description> <command:parameterValueGroup> <command:parameterValue required="false" variableLength="false">Process</command:parameterValue> <command:parameterValue required="false" variableLength="false">CurrentUser</command:parameterValue> <command:parameterValue required="false" variableLength="false">LocalMachine</command:parameterValue> <command:parameterValue required="false" variableLength="false">UserPolicy</command:parameterValue> <command:parameterValue required="false" variableLength="false">MachinePolicy</command:parameterValue> </command:parameterValueGroup> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named"> <maml:name>List</maml:name> <maml:description> <maml:para>取得工作階段的所有執行原則值,並依優先順序列出。根據預設,Get-ExecutionPolicy 只會取得有效的執行原則。 </maml:para> </maml:description> </command:parameter> </command:syntaxItem> </command:syntax> <!-- Cmdlet parameter section --> <command:parameters> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named"> <maml:name>List</maml:name> <maml:description> <maml:para>取得工作階段的所有執行原則值,並依優先順序列出。根據預設,Get-ExecutionPolicy 只會取得有效的執行原則。 </maml:para> </maml:description> <command:parameterValue required="false" variableLength="false">SwitchParameter</command:parameterValue> <dev:type> <maml:name>SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>False</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="true (ByPropertyName)" position="1"> <maml:name>Scope</maml:name> <maml:description> <maml:para>取得指定之範圍中的執行原則。根據預設,Get-ExecutionPolicy 會取得目前工作階段的有效執行原則。 有效的值包括: -- MachinePolicy:所有電腦使用者之群組原則所設定的執行原則。 -- UserPolicy:目前電腦使用者之群組原則所設定的執行原則。 -- Process:針對目前 Windows PowerShell 處理序所設定的執行原則。 -- CurrentUser:針對目前使用者所設定的執行原則。 -- LocalMachine:針對所有電腦使用者所設定的執行原則。</maml:para> </maml:description> <command:parameterValue required="true" variableLength="false">ExecutionPolicyScope</command:parameterValue> <dev:type> <maml:name>ExecutionPolicyScope</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>有效的執行原則</dev:defaultValue> </command:parameter> </command:parameters> <!-- Input - Output section--> <command:inputTypes> <command:inputType> <dev:type> <maml:name>無</maml:name> <maml:uri /> <maml:description /> </dev:type> <maml:description> <maml:para> <!-- description --> 您無法經由管道將輸入輸出至這個 Cmdlet。 </maml:para> </maml:description> </command:inputType> </command:inputTypes> <command:returnValues> <command:returnValue> <dev:type> <maml:name>Microsoft.PowerShell.ExecutionPolicy</maml:name> <maml:uri /> <maml:description /> </dev:type> <maml:description> <maml:para> <!-- description --> Get-ExecutionPolicy 會針對它所取得的每個執行原則傳回一個物件。 </maml:para> </maml:description> </command:returnValue> </command:returnValues> <!-- Error section--> <command:terminatingErrors /> <command:nonTerminatingErrors /> <!-- Notes section --> <maml:alertSet> <maml:title></maml:title> <maml:alert> <maml:para> 您無法使用 Get-ExecutionPolicy 取得針對特定範圍而設定的特定執行原則,或取得由群組原則所設定的執行原則。Get-ExecutionPolicy 只能取得由套用所有的優先順序規則而產生的有效執行原則。 執行原則是 Windows PowerShell 安全性策略的一部分。它決定您可否載入組態檔 (包括 Windows PowerShell 設定檔) 及執行指令碼,同時也決定哪些指令碼 (如果有的話) 必須先經過數位簽署才能執行。 有效的執行原則是由您使用 Set-ExecutionPolicy 所設定的原則以及電腦和使用者的「開啟指令碼執行」群組原則來決定。優先順序為:電腦群組原則 > 使用者群組原則 > 處理序 (工作階段) 執行原則 > 使用者執行原則 > 電腦執行原則。 如需 Windows PowerShell 執行原則的詳細資訊,包括 Windows PowerShell 原則的定義,請參閱 about_Execution_Policies。 </maml:para> </maml:alert> <maml:alert> <maml:para></maml:para> </maml:alert> </maml:alertSet> <!-- Example section --> <command:examples> <command:example> <maml:title> -------------------------- 範例 1 -------------------------- </maml:title> <maml:introduction> <maml:para>C:\PS></maml:para> </maml:introduction> <dev:code> get-executionpolicy Restricted </dev:code> <dev:remarks> <maml:para>描述</maml:para> <maml:para>-----------</maml:para> <maml:para>這個命令會取得殼層的目前執行原則。</maml:para> <maml:para></maml:para> <maml:para></maml:para> <maml:para></maml:para> <maml:para></maml:para> </dev:remarks> <command:commandLines> <command:commandLine> <command:commandText></command:commandText> </command:commandLine> </command:commandLines> </command:example> <command:example> <maml:title> -------------------------- 範例 2 -------------------------- </maml:title> <maml:introduction> <maml:para>C:\PS></maml:para> </maml:introduction> <dev:code> set-executionpolicy RemoteSigned; get-executionPolicy RemoteSigned </dev:code> <dev:remarks> <maml:para>描述</maml:para> <maml:para>-----------</maml:para> <maml:para>這些命令為殼層執行原則設定新的使用者偏好設定,然後顯示有效的執行原則。命令以分號 (;) 作分隔。在這個範例中,因為沒有群組原則設定,所以使用者喜好設定即是殼層的有效原則。</maml:para> <maml:para></maml:para> <maml:para></maml:para> <maml:para></maml:para> <maml:para></maml:para> </dev:remarks> <command:commandLines> <command:commandLine> <command:commandText></command:commandText> </command:commandLine> </command:commandLines> </command:example> <command:example> <maml:title> -------------------------- 範例 3 -------------------------- </maml:title> <maml:introduction> <maml:para>C:\PS></maml:para> </maml:introduction> <dev:code> get-executionpolicy -list Scope ExecutionPolicy ----- --------------- MachinePolicy Undefined UserPolicy Undefined Process Undefined CurrentUser AllSigned LocalMachine RemoteSigned C:\PS> get-executionpolicy AllSigned </dev:code> <dev:remarks> <maml:para>描述</maml:para> <maml:para>-----------</maml:para> <maml:para>這些命令會取得目前工作階段中的所有執行原則以及有效的執行原則。 第一個命令會取得影響目前工作階段的所有執行原則。這些原則會依優先順序列出。 第二個命令只會取得有效的執行原則,亦即 CurrentUser 範圍中設定的執行原則。</maml:para> <maml:para></maml:para> <maml:para></maml:para> <maml:para></maml:para> <maml:para></maml:para> </dev:remarks> <command:commandLines> <command:commandLine> <command:commandText></command:commandText> </command:commandLine> </command:commandLines> </command:example> </command:examples> <!-- Link section --> <maml:relatedLinks> <maml:navigationLink> <maml:linkText>Online version:</maml:linkText> <maml:uri>http://go.microsoft.com/fwlink/?LinkID=113315</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Set-ExecutionPolicy</maml:linkText> <maml:uri /> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Get-AuthenticodeSignature</maml:linkText> <maml:uri /> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Set-AuthenticodeSignature</maml:linkText> <maml:uri /> </maml:navigationLink> <maml:navigationLink> <maml:linkText>about_Execution_Policies</maml:linkText> <maml:uri /> </maml:navigationLink> <maml:navigationLink> <maml:linkText>about_Signing</maml:linkText> <maml:uri /> </maml:navigationLink> </maml:relatedLinks> </command:command> <!-- v 1.1.0.9 --> <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10"> <command:details> <command:name> Get-PfxCertificate </command:name> <maml:description> <maml:para>取得電腦中 .pfx 憑證檔案的相關資訊。</maml:para> </maml:description> <maml:copyright> <maml:para></maml:para> </maml:copyright> <command:verb>Get</command:verb> <command:noun>PfxCertificate</command:noun> <dev:version></dev:version> </command:details> <maml:description> <maml:para>Get-PfxCertificate Cmdlet 會取得代表每個指定之 .pfx 憑證檔案的物件。.pfx 檔案同時包含憑證及私密金鑰。</maml:para> </maml:description> <!-- Cmdlet syntax section--> <command:syntax> <command:syntaxItem> <maml:name>Get-PfxCertificate</maml:name> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="true (ByValue, ByPropertyName)" position="1"> <maml:name>FilePath</maml:name> <maml:description> <maml:para>受保護檔案的 .pfx 檔案完整路徑。參數名稱 ("FilePath") 為選擇項。</maml:para> </maml:description> <command:parameterValue required="true" variableLength="true">string[]</command:parameterValue> </command:parameter> </command:syntaxItem> </command:syntax> <!-- Cmdlet parameter section --> <command:parameters> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="true (ByValue, ByPropertyName)" position="1"> <maml:name>FilePath</maml:name> <maml:description> <maml:para>受保護檔案的 .pfx 檔案完整路徑。參數名稱 ("FilePath") 為選擇項。</maml:para> </maml:description> <command:parameterValue required="true" variableLength="true">string[]</command:parameterValue> <dev:type> <maml:name>string[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue></dev:defaultValue> </command:parameter> </command:parameters> <!-- Input - Output section--> <command:inputTypes> <command:inputType> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> <maml:description /> </dev:type> <maml:description> <maml:para> <!-- description --> 您可經由管道將包含檔案路徑的字串輸出至 Get-PfxCertificate。 </maml:para> </maml:description> </command:inputType> </command:inputTypes> <command:returnValues> <command:returnValue> <dev:type> <maml:name>System.Security.Cryptography.X509Certificates</maml:name> <maml:uri /> <maml:description /> </dev:type> <maml:description> <maml:para> <!-- description --> Get-PfxCertificate 會針對它所取得的每個憑證傳回一個物件。 </maml:para> </maml:description> </command:returnValue> </command:returnValues> <!-- Error section--> <command:terminatingErrors /> <command:nonTerminatingErrors /> <!-- Notes section --> <maml:alertSet> <maml:title></maml:title> <maml:alert> <maml:para> 如果使用 Invoke-Command Cmdlet 在遠端執行 Get-PfxCertificate 命令,而且 .pfx 憑證檔案未受到密碼保護,則 Invoke-Command 的 Authentication 參數值必須為 "CredSSP"。 </maml:para> </maml:alert> <maml:alert> <maml:para></maml:para> </maml:alert> </maml:alertSet> <!-- Example section --> <command:examples> <command:example> <maml:title> -------------------------- 範例 1 -------------------------- </maml:title> <maml:introduction> <maml:para>C:\PS></maml:para> </maml:introduction> <dev:code> get-pfxcertificate -filepath C:\windows\system32\Test.pfx Password: ****** Signer Certificate: Matt Berg (Self Certificate) Time Certificate: Time Stamp: Path: C:\windows\system32\zap.pfx </dev:code> <dev:remarks> <maml:para>描述</maml:para> <maml:para>-----------</maml:para> <maml:para>這個命令取得系統中 Test.pfx 憑證的相關資訊。</maml:para> <maml:para></maml:para> <maml:para></maml:para> <maml:para></maml:para> <maml:para></maml:para> </dev:remarks> <command:commandLines> <command:commandLine> <command:commandText></command:commandText> </command:commandLine> </command:commandLines> </command:example> <command:example> <maml:title> -------------------------- 範例 2 -------------------------- </maml:title> <maml:introduction> <maml:para>C:\PS></maml:para> </maml:introduction> <dev:code> invoke-command -computername Server01 -scriptblock {get-pfxcertificate -filepath C:\Text\TestNoPassword.pfx} -authentication CredSSP </dev:code> <dev:remarks> <maml:para>描述</maml:para> <maml:para>-----------</maml:para> <maml:para>這個命令會從 Server01 遠端電腦取得 .pfx 憑證檔案。它會使用 Invoke-Command 在遠端執行 Get-PfxCertificate 命令。 如果 .pfx 憑證檔案未受到密碼保護,則 Invoke-Command 的 Authentication 參數值必須為 "CredSSP"。</maml:para> <maml:para></maml:para> <maml:para></maml:para> <maml:para></maml:para> <maml:para></maml:para> </dev:remarks> <command:commandLines> <command:commandLine> <command:commandText></command:commandText> </command:commandLine> </command:commandLines> </command:example> </command:examples> <!-- Link section --> <maml:relatedLinks> <maml:navigationLink> <maml:linkText>Online version:</maml:linkText> <maml:uri>http://go.microsoft.com/fwlink/?LinkID=113323</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Get-AuthenticodeSignature</maml:linkText> <maml:uri /> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Set-AuthenticodeSignature</maml:linkText> <maml:uri /> </maml:navigationLink> <maml:navigationLink> <maml:linkText>about_Signing</maml:linkText> <maml:uri /> </maml:navigationLink> </maml:relatedLinks> </command:command> <!-- v 1.1.0.9 --> <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10"> <command:details> <command:name> Set-Acl </command:name> <maml:description> <maml:para>變更指定資源 (如檔案或登錄機碼) 的安全性描述元。</maml:para> </maml:description> <maml:copyright> <maml:para></maml:para> </maml:copyright> <command:verb>Set</command:verb> <command:noun>Acl</command:noun> <dev:version></dev:version> </command:details> <maml:description> <maml:para>Set-Acl Cmdlet 會變更指定之資源 (如檔案或登錄機碼) 的安全性描述元,以符合您所提供之安全性描述元中的值。 若要使用 Set-Acl,請使用 Path 參數來識別要變更其安全性描述元的資源,並使用 AclObject 參數來提供要套用其值的安全性描述元。Set-Acl 會使用 AclObject 參數的值做為模型,並變更資源之安全性描述元中的值,以符合 AclObject 參數所指定之安全性描述元中的值。</maml:para> </maml:description> <!-- Cmdlet syntax section--> <command:syntax> <command:syntaxItem> <maml:name>Set-Acl</maml:name> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="true (ByPropertyName)" position="1"> <maml:name>Path</maml:name> <maml:description> <maml:para>識別要變更其安全性描述元的資源。輸入資源的路徑,例如檔案或登錄機碼的路徑。允許使用萬用字元。 若將安全性物件傳遞給 Set-Acl (使用 AclObject 參數,或從 Get-Acl 傳遞物件給 Set-Acl) 並且省略 Path 參數 (名稱和值),Set-Acl 會使用包含在安全性物件中的路徑。</maml:para> </maml:description> <command:parameterValue required="true" variableLength="true">string[]</command:parameterValue> </command:parameter> <command:parameter required="true" variableLength="false" globbing="false" pipelineInput="true (ByValue)" position="2"> <maml:name>AclObject</maml:name> <maml:description> <maml:para>使用所要的屬性值指定 ACL。Set-Acl 會將 Path 參數所指定資源的 ACL 變更為符合指定的安全性物件中的值。 您可以將 Get-Acl 命令的輸出儲存至變數,再使用 AclObject 參數來傳遞變數,或是輸入 Get-Acl 命令。</maml:para> </maml:description> <command:parameterValue required="true" variableLength="false">ObjectSecurity</command:parameterValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="false" position="named"> <maml:name>Exclude</maml:name> <maml:description> <maml:para>忽略指定的項目。此參數的值用於限定 Path 參數。輸入路徑元素或模式,例如 "*.txt"。允許使用萬用字元。</maml:para> </maml:description> <command:parameterValue required="true" variableLength="true">string[]</command:parameterValue> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named"> <maml:name>Filter</maml:name> <maml:description> <maml:para>指定以提供者的格式或語言表示的篩選器。此參數的值用於限定 Path 參數。篩選器的語法 (包括萬用字元的用法) 依提供者而定。篩選器比其他參數更有效率,因為提供者會在擷取物件時套用篩選器,而非等到 Windows PowerShell 擷取物件後才進行篩選。</maml:para> </maml:description> <command:parameterValue required="true" variableLength="false">string</command:parameterValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="false" position="named"> <maml:name>Include</maml:name> <maml:description> <maml:para>只變更指定的項目。此參數的值用於限定 Path 參數。輸入路徑元素或模式,例如 "*.txt"。允許使用萬用字元。</maml:para> </maml:description> <command:parameterValue required="true" variableLength="true">string[]</command:parameterValue> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named"> <maml:name>PassThru</maml:name> <maml:description> <maml:para>傳回代表安全性描述元的物件。根據預設,此 Cmdlet 不會產生任何輸出。</maml:para> </maml:description> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="false" position="named"> <maml:name>Confirm</maml:name> <maml:description> <maml:para>在執行命令前先提示確認。</maml:para> </maml:description> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="false" position="named"> <maml:name>WhatIf</maml:name> <maml:description> <maml:para>說明執行命令時將會發生何種情況,但不會實際執行命令。</maml:para> </maml:description> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="false" position="named"> <maml:name>UseTransaction</maml:name> <maml:description> <maml:para>將命令加入現用交易中。此參數只有當交易進行中時才有效。如需詳細資訊,請參閱 about_Transactions。</maml:para> </maml:description> </command:parameter> </command:syntaxItem> </command:syntax> <!-- Cmdlet parameter section --> <command:parameters> <command:parameter required="true" variableLength="false" globbing="false" pipelineInput="true (ByValue)" position="2"> <maml:name>AclObject</maml:name> <maml:description> <maml:para>使用所要的屬性值指定 ACL。Set-Acl 會將 Path 參數所指定資源的 ACL 變更為符合指定的安全性物件中的值。 您可以將 Get-Acl 命令的輸出儲存至變數,再使用 AclObject 參數來傳遞變數,或是輸入 Get-Acl 命令。</maml:para> </maml:description> <command:parameterValue required="true" variableLength="false">ObjectSecurity</command:parameterValue> <dev:type> <maml:name>ObjectSecurity</maml:name> <maml:uri /> </dev:type> <dev:defaultValue></dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="false" position="named"> <maml:name>Exclude</maml:name> <maml:description> <maml:para>忽略指定的項目。此參數的值用於限定 Path 參數。輸入路徑元素或模式,例如 "*.txt"。允許使用萬用字元。</maml:para> </maml:description> <command:parameterValue required="true" variableLength="true">string[]</command:parameterValue> <dev:type> <maml:name>string[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue></dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named"> <maml:name>Filter</maml:name> <maml:description> <maml:para>指定以提供者的格式或語言表示的篩選器。此參數的值用於限定 Path 參數。篩選器的語法 (包括萬用字元的用法) 依提供者而定。篩選器比其他參數更有效率,因為提供者會在擷取物件時套用篩選器,而非等到 Windows PowerShell 擷取物件後才進行篩選。</maml:para> </maml:description> <command:parameterValue required="true" variableLength="false">string</command:parameterValue> <dev:type> <maml:name>string</maml:name> <maml:uri /> </dev:type> <dev:defaultValue></dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="false" position="named"> <maml:name>Include</maml:name> <maml:description> <maml:para>只變更指定的項目。此參數的值用於限定 Path 參數。輸入路徑元素或模式,例如 "*.txt"。允許使用萬用字元。</maml:para> </maml:description> <command:parameterValue required="true" variableLength="true">string[]</command:parameterValue> <dev:type> <maml:name>string[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue></dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named"> <maml:name>PassThru</maml:name> <maml:description> <maml:para>傳回代表安全性描述元的物件。根據預設,此 Cmdlet 不會產生任何輸出。</maml:para> </maml:description> <command:parameterValue required="false" variableLength="false">SwitchParameter</command:parameterValue> <dev:type> <maml:name>SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue></dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="true (ByPropertyName)" position="1"> <maml:name>Path</maml:name> <maml:description> <maml:para>識別要變更其安全性描述元的資源。輸入資源的路徑,例如檔案或登錄機碼的路徑。允許使用萬用字元。 若將安全性物件傳遞給 Set-Acl (使用 AclObject 參數,或從 Get-Acl 傳遞物件給 Set-Acl) 並且省略 Path 參數 (名稱和值),Set-Acl 會使用包含在安全性物件中的路徑。</maml:para> </maml:description> <command:parameterValue required="true" variableLength="true">string[]</command:parameterValue> <dev:type> <maml:name>string[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue></dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="false" position="named"> <maml:name>Confirm</maml:name> <maml:description> <maml:para>在執行命令前先提示確認。</maml:para> </maml:description> <command:parameterValue required="false" variableLength="false">SwitchParameter</command:parameterValue> <dev:type> <maml:name>SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue /> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="false" position="named"> <maml:name>WhatIf</maml:name> <maml:description> <maml:para>說明執行命令時將會發生何種情況,但不會實際執行命令。</maml:para> </maml:description> <command:parameterValue required="false" variableLength="false">SwitchParameter</command:parameterValue> <dev:type> <maml:name>SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue /> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="false" position="named"> <maml:name>UseTransaction</maml:name> <maml:description> <maml:para>將命令加入現用交易中。此參數只有當交易進行中時才有效。如需詳細資訊,請參閱 about_Transactions。</maml:para> </maml:description> <command:parameterValue required="false" variableLength="false">SwitchParameter</command:parameterValue> <dev:type> <maml:name>SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue /> </command:parameter> </command:parameters> <!-- Input - Output section--> <command:inputTypes> <command:inputType> <dev:type> <maml:name>System.Security.AccessControl.ObjectSecurity</maml:name> <maml:uri /> <maml:description /> </dev:type> <maml:description> <maml:para> <!-- description --> 您可經由管道將安全性描述元輸出至 Set-Acl。 </maml:para> </maml:description> </command:inputType> </command:inputTypes> <command:returnValues> <command:returnValue> <dev:type> <maml:name>無或安全性物件</maml:name> <maml:uri /> <maml:description /> </dev:type> <maml:description> <maml:para> <!-- description --> 根據預設,Set-Acl 不會產生任何輸出。不過,如果您使用 -Passthru 參數,它就會產生安全性物件。安全性物件的類型是依資源類型而定。 </maml:para> </maml:description> </command:returnValue> </command:returnValues> <!-- Error section--> <command:terminatingErrors /> <command:nonTerminatingErrors /> <!-- Notes section --> <maml:alertSet> <maml:title></maml:title> <maml:alert> <maml:para> Windows PowerShell FileSystem 和 Registry 提供者支援 Set-Acl Cmdlet。因此,您可以用它來變更檔案、目錄和登錄機碼的安全性描述元。 若要為參數指定多重數值,請使用逗號來分隔數值。例如:"<參數名稱> <值1>, <值2>"。 </maml:para> </maml:alert> <maml:alert> <maml:para></maml:para> </maml:alert> </maml:alertSet> <!-- Example section --> <command:examples> <command:example> <maml:title> -------------------------- 範例 1 -------------------------- </maml:title> <maml:introduction> <maml:para>C:\PS></maml:para> </maml:introduction> <dev:code> $DogACL = get-acl c:\dog.txt C:\PS>set-acl -path C:\cat.txt -AclObject $DogACL </dev:code> <dev:remarks> <maml:para>描述</maml:para> <maml:para>-----------</maml:para> <maml:para>這些命令會從 Dog.txt 檔案的安全性描述元,將這些值複製到 Cat.txt 檔案的安全性描述元。當命令完成時,Dog.txt 與 Cat.txt 檔案的安全性描述元將會完全相同。 第一個命令會使用 Get-Acl Cmdlet 取得 Dog.txt 檔案的安全性描述元。指定運算子 (=) 將安全性描述元儲存在 $DogACL 變數的值中。 第二個命令會使用 Set-Acl,將 Cat.txt 中的 ACL 值變更為 $DogACL 的值。 Path 參數的值為 Cat.txt 檔案的路徑。AclObject 參數的值是模型 ACL;在此例為 Dog.txt 的 ACL (儲存於 $DogACL 變數)。</maml:para> <maml:para></maml:para> <maml:para></maml:para> <maml:para></maml:para> <maml:para></maml:para> </dev:remarks> <command:commandLines> <command:commandLine> <command:commandText></command:commandText> </command:commandLine> </command:commandLines> </command:example> <command:example> <maml:title> -------------------------- 範例 2 -------------------------- </maml:title> <maml:introduction> <maml:para>C:\PS></maml:para> </maml:introduction> <dev:code> get-acl c:\dog.txt | set-acl -path C:\cat.txt </dev:code> <dev:remarks> <maml:para>描述</maml:para> <maml:para>-----------</maml:para> <maml:para>這個命令與前一個範例中的命令幾乎相同,只是使用了管線運算子將 Get-Acl 命令中擷取的安全性描述元傳送至 Set-Acl 命令。 第一個命令會使用 Get-Acl Cmdlet 取得 Dog.txt 檔案的安全性描述元。管線運算子 (|) 將代表 Dog.txt 安全性描述元的物件傳遞給 Set-Acl 命令。 第二個命令會使用 Set-Acl,將 Dog.txt 的安全性描述元套用至 Cat.txt。當命令完成時,Dog.txt 與 Cat.txt 檔案的 ACL 將會完全相同。</maml:para> <maml:para></maml:para> <maml:para></maml:para> <maml:para></maml:para> <maml:para></maml:para> </dev:remarks> <command:commandLines> <command:commandLine> <command:commandText></command:commandText> </command:commandLine> </command:commandLines> </command:example> <command:example> <maml:title> -------------------------- 範例 3 -------------------------- </maml:title> <maml:introduction> <maml:para>C:\PS></maml:para> </maml:introduction> <dev:code> $newACL = get-acl file0.txt C:\PS>get-childitem c:\temp -recurse -include *.txt -force | set-acl -aclobject $newacl </dev:code> <dev:remarks> <maml:para>描述</maml:para> <maml:para>-----------</maml:para> <maml:para>這些命令將 File0.txt 檔案中的安全性描述元套用至 C:\Temp 目錄及其所有子目錄中的所有文字檔。 第一個命令取得目前目錄中 File0.txt 檔案的安全性描述元,並使用指定運算子 (=) 將它儲存在 $newACL 變數中。 管線中的第一個命令會使用 Get-ChildItem Cmdlet 來取得 C:\Temp 目錄中的所有文字檔。Recurse 參數將命令擴及 C:\temp 中的所有子目錄。Include 參數將擷取的檔案限制為那些帶有 ".txt" 副檔名的檔案。Force 參數可取得隱藏檔案,若不使用此參數,便會將這些檔案排除在外 (您不能使用 "c:\temp\*.txt",因為 Recurse 參數適用於目錄,但對檔案無效)。 管線運算子 (|) 將代表所擷取檔案的物件傳送到 Set-Acl 命令,後者再將 AclObject 參數中的安全性描述元套用至管線中的所有檔案。 實際上,最好的作法是使用 Whatif 參數搭配所有可影響多個資源的 Set-Acl 命令。在此例中,管線中的第二個命令將會是 "set-acl -aclobject $newacl -whatif"。這個命令會列出受到命令影響的檔案。在檢閱結果之後,您可以再一次執行此命令,但是這次不使用 Whatif 參數。</maml:para> <maml:para></maml:para> <maml:para></maml:para> <maml:para></maml:para> <maml:para></maml:para> </dev:remarks> <command:commandLines> <command:commandLine> <command:commandText></command:commandText> </command:commandLine> </command:commandLines> </command:example> </command:examples> <!-- Link section --> <maml:relatedLinks> <maml:navigationLink> <maml:linkText>Online version:</maml:linkText> <maml:uri>http://go.microsoft.com/fwlink/?LinkID=113389</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Get-Acl</maml:linkText> <maml:uri /> </maml:navigationLink> </maml:relatedLinks> </command:command> <!-- v 1.1.0.9 --> <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10"> <command:details> <command:name> Set-AuthenticodeSignature </command:name> <maml:description> <maml:para>將 Authenticode 簽章新增至 Windows PowerShell 指令碼或其他檔案。</maml:para> </maml:description> <maml:copyright> <maml:para></maml:para> </maml:copyright> <command:verb>Set</command:verb> <command:noun>AuthenticodeSignature</command:noun> <dev:version></dev:version> </command:details> <maml:description> <maml:para>Set-AuthenticodeSignature Cmdlet 會將 Authenticode 簽章新增至任何支援 Subject Interface Package (SIP) 的檔案。 在 Windows PowerShell 指令碼檔案中,簽章是以文字區塊的形式出現,可指出指令碼所執行之指令的結尾。如果執行此 Cmdlet 時檔案中已經有簽章,會移除該簽章。</maml:para> </maml:description> <!-- Cmdlet syntax section--> <command:syntax> <command:syntaxItem> <maml:name>Set-AuthenticodeSignature</maml:name> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="true (ByValue, ByPropertyName)" position="1"> <maml:name>FilePath</maml:name> <maml:description> <maml:para>指定要簽署的檔案所在路徑。</maml:para> </maml:description> <command:parameterValue required="true" variableLength="true">string[]</command:parameterValue> </command:parameter> <command:parameter required="true" variableLength="false" globbing="false" pipelineInput="false" position="2"> <maml:name>Certificate</maml:name> <maml:description> <maml:para>指定用來簽署指令碼或檔案的憑證。輸入已儲存代表憑證之物件的變數,或是可取得憑證的運算式。 若要尋找憑證,請使用 Get-PfxCertificate 或在 Certificate (Cert:) 磁碟機中使用 Get-ChildItem Cmdlet。如果憑證無效或未持有程式碼簽署授權,命令便會失敗。</maml:para> </maml:description> <command:parameterValue required="true" variableLength="false">X509Certificate2</command:parameterValue> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named"> <maml:name>Force</maml:name> <maml:description> <maml:para>允許此 Cmdlet 將簽章附加至唯讀的檔案。即便使用 Force 參數,此 Cmdlet 也無法覆寫安全性限制。</maml:para> </maml:description> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named"> <maml:name>HashAlgorithm</maml:name> <maml:description> <maml:para>指定 Windows 用來計算檔案數位簽章的雜湊演算法。預設值為 SHA1,亦即 Windows 預設雜湊演算法。 使用不同雜湊演算法簽署的檔案可能無法在其他系統上辨識。</maml:para> </maml:description> <command:parameterValue required="true" variableLength="false">string</command:parameterValue> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named"> <maml:name>IncludeChain</maml:name> <maml:description> <maml:para>決定要將憑證信任鏈結上的哪些憑證包含在數位簽章中。預設值為 "NotRoot"。 有效的值包括: -- Signer:只包含簽署者的憑證。 -- NotRoot:包含憑證鏈結中的所有憑證,唯獨根授權除外。 --All:包含憑證鏈結中的所有憑證。</maml:para> </maml:description> <command:parameterValue required="true" variableLength="false">string</command:parameterValue> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named"> <maml:name>TimestampServer</maml:name> <maml:description> <maml:para>使用指定的時間戳記伺服器,將時間戳記新增到簽章。請以字串形式輸入時間戳記伺服器的 URL。 時間戳記表示憑證加入至檔案的確切時間。如果憑證過期,時間戳記可避免指令碼失敗,因為使用者和程式可以確認憑證在簽署時是有效的。</maml:para> </maml:description> <command:parameterValue required="true" variableLength="false">string</command:parameterValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="false" position="named"> <maml:name>Confirm</maml:name> <maml:description> <maml:para>在執行命令前先提示確認。</maml:para> </maml:description> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="false" position="named"> <maml:name>WhatIf</maml:name> <maml:description> <maml:para>說明執行命令時將會發生何種情況,但不會實際執行命令。</maml:para> </maml:description> </command:parameter> </command:syntaxItem> </command:syntax> <!-- Cmdlet parameter section --> <command:parameters> <command:parameter required="true" variableLength="false" globbing="false" pipelineInput="false" position="2"> <maml:name>Certificate</maml:name> <maml:description> <maml:para>指定用來簽署指令碼或檔案的憑證。輸入已儲存代表憑證之物件的變數,或是可取得憑證的運算式。 若要尋找憑證,請使用 Get-PfxCertificate 或在 Certificate (Cert:) 磁碟機中使用 Get-ChildItem Cmdlet。如果憑證無效或未持有程式碼簽署授權,命令便會失敗。</maml:para> </maml:description> <command:parameterValue required="true" variableLength="false">X509Certificate2</command:parameterValue> <dev:type> <maml:name>X509Certificate2</maml:name> <maml:uri /> </dev:type> <dev:defaultValue></dev:defaultValue> </command:parameter> <command:parameter required="true" variableLength="true" globbing="false" pipelineInput="true (ByValue, ByPropertyName)" position="1"> <maml:name>FilePath</maml:name> <maml:description> <maml:para>指定要簽署的檔案所在路徑。</maml:para> </maml:description> <command:parameterValue required="true" variableLength="true">string[]</command:parameterValue> <dev:type> <maml:name>string[]</maml:name> <maml:uri /> </dev:type> <dev:defaultValue></dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named"> <maml:name>Force</maml:name> <maml:description> <maml:para>允許此 Cmdlet 將簽章附加至唯讀的檔案。即便使用 Force 參數,此 Cmdlet 也無法覆寫安全性限制。</maml:para> </maml:description> <command:parameterValue required="false" variableLength="false">SwitchParameter</command:parameterValue> <dev:type> <maml:name>SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue></dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named"> <maml:name>HashAlgorithm</maml:name> <maml:description> <maml:para>指定 Windows 用來計算檔案數位簽章的雜湊演算法。預設值為 SHA1,亦即 Windows 預設雜湊演算法。 使用不同雜湊演算法簽署的檔案可能無法在其他系統上辨識。</maml:para> </maml:description> <command:parameterValue required="true" variableLength="false">string</command:parameterValue> <dev:type> <maml:name>string</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>SHA1</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named"> <maml:name>IncludeChain</maml:name> <maml:description> <maml:para>決定要將憑證信任鏈結上的哪些憑證包含在數位簽章中。預設值為 "NotRoot"。 有效的值包括: -- Signer:只包含簽署者的憑證。 -- NotRoot:包含憑證鏈結中的所有憑證,唯獨根授權除外。 --All:包含憑證鏈結中的所有憑證。</maml:para> </maml:description> <command:parameterValue required="true" variableLength="false">string</command:parameterValue> <dev:type> <maml:name>string</maml:name> <maml:uri /> </dev:type> <dev:defaultValue></dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named"> <maml:name>TimestampServer</maml:name> <maml:description> <maml:para>使用指定的時間戳記伺服器,將時間戳記新增到簽章。請以字串形式輸入時間戳記伺服器的 URL。 時間戳記表示憑證加入至檔案的確切時間。如果憑證過期,時間戳記可避免指令碼失敗,因為使用者和程式可以確認憑證在簽署時是有效的。</maml:para> </maml:description> <command:parameterValue required="true" variableLength="false">string</command:parameterValue> <dev:type> <maml:name>string</maml:name> <maml:uri /> </dev:type> <dev:defaultValue></dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="false" position="named"> <maml:name>Confirm</maml:name> <maml:description> <maml:para>在執行命令前先提示確認。</maml:para> </maml:description> <command:parameterValue required="false" variableLength="false">SwitchParameter</command:parameterValue> <dev:type> <maml:name>SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue /> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="false" position="named"> <maml:name>WhatIf</maml:name> <maml:description> <maml:para>說明執行命令時將會發生何種情況,但不會實際執行命令。</maml:para> </maml:description> <command:parameterValue required="false" variableLength="false">SwitchParameter</command:parameterValue> <dev:type> <maml:name>SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue /> </command:parameter> </command:parameters> <!-- Input - Output section--> <command:inputTypes> <command:inputType> <dev:type> <maml:name>System.String</maml:name> <maml:uri /> <maml:description /> </dev:type> <maml:description> <maml:para> <!-- description --> 您可經由管道將包含檔案路徑的字串輸出至 Set-AuthenticodeSignature。 </maml:para> </maml:description> </command:inputType> </command:inputTypes> <command:returnValues> <command:returnValue> <dev:type> <maml:name>System.Management.Automation.Signature</maml:name> <maml:uri /> <maml:description /> </dev:type> <maml:description> <maml:para> <!-- description --> </maml:para> </maml:description> </command:returnValue> </command:returnValues> <!-- Error section--> <command:terminatingErrors /> <command:nonTerminatingErrors /> <!-- Notes section --> <maml:alertSet> <maml:title></maml:title> <maml:alert> <maml:para> </maml:para> </maml:alert> <maml:alert> <maml:para></maml:para> </maml:alert> </maml:alertSet> <!-- Example section --> <command:examples> <command:example> <maml:title> -------------------------- 範例 1 -------------------------- </maml:title> <maml:introduction> <maml:para>C:\PS></maml:para> </maml:introduction> <dev:code> $cert=Get-ChildItem -Path cert:\CurrentUser\my -CodeSigningCert C:\PS>Set-AuthenticodeSignature -FilePath PsTestInternet2.ps1 -certificate $cert </dev:code> <dev:remarks> <maml:para>描述</maml:para> <maml:para>-----------</maml:para> <maml:para>這些命令會從 Windows PowerShell Certificate 提供者擷取程式碼簽署憑證,並用它來簽署 Windows PowerShell 指令碼。 第一個命令會使用 Get-ChildItem Cmdlet 和 Windows PowerShell Certificate 提供者來取得憑證存放區之 Cert:\CurrentUser\My 子目錄中的憑證 (Cert: 磁碟機是 Certificate 提供者所公開的磁碟機)。CodeSigningCert 參數 (只有 Certificate 提供者才支援) 會將擷取的憑證限制為那些具有程式碼簽署授權的憑證。命令會在 $cert 變數中儲存結果。 第二個命令會使用 Set-AuthenticodeSignature Cmdlet 來簽署 PSTestInternet2.ps1 指令碼。它會使用 FilePath 參數指定指令碼的名稱,並使用 Certificate 參數指定要在 $cert 變數中儲存憑證。</maml:para> <maml:para></maml:para> <maml:para></maml:para> <maml:para></maml:para> <maml:para></maml:para> </dev:remarks> <command:commandLines> <command:commandLine> <command:commandText></command:commandText> </command:commandLine> </command:commandLines> </command:example> <command:example> <maml:title> -------------------------- 範例 2 -------------------------- </maml:title> <maml:introduction> <maml:para>C:\PS></maml:para> </maml:introduction> <dev:code> $cert = Get-PfxCertificate C:\Test\Mysign.pfx C:\PS>Set-AuthenticodeSignature -Filepath ServerProps.ps1 -Cert $cert </dev:code> <dev:remarks> <maml:para>描述</maml:para> <maml:para>-----------</maml:para> <maml:para>這些命令會使用 Get-PfxCertificate Cmdlet 來尋找程式碼簽署憑證。然後,它們會使用此憑證來簽署 Windows PowerShell 指令碼。 第一個命令會使用 Get-PfxCertificate Cmdlet 來尋找 C:\Test\MySign.pfx 憑證,並將它儲存在 $cert 變數中。 第二個命令會使用 Set-AuthenticodeSignature 來簽署指令碼。Set-AuthenticodeSignature 的 FilePath 參數會指定所簽署之指令碼檔案的路徑,而 Cert 參數則將含有憑證的 $cert 變數傳遞給 Set-AuthenticodeSignature。 如果憑證檔案受到密碼保護,Windows PowerShell 會提示您提供密碼。</maml:para> <maml:para></maml:para> <maml:para></maml:para> <maml:para></maml:para> <maml:para></maml:para> </dev:remarks> <command:commandLines> <command:commandLine> <command:commandText></command:commandText> </command:commandLine> </command:commandLines> </command:example> <command:example> <maml:title> -------------------------- 範例 3 -------------------------- </maml:title> <maml:introduction> <maml:para>C:\PS></maml:para> </maml:introduction> <dev:code> Set-AuthenticodeSignature -filepath c:\scripts\Remodel.ps1 -certificate $cert -IncludeChain All -TimeStampServer "http://timestamp.fabrikam.com/scripts/timstamper.dll" </dev:code> <dev:remarks> <maml:para>描述</maml:para> <maml:para>-----------</maml:para> <maml:para>這個命令會新增數位簽章,以便將根授權包含在信任鏈結中,並交由第三方時間戳記伺服器來簽署。 此命令會使用 FilePath 參數指定要簽署的指令碼,並使用 Certificate 參數指定要在 $cert 變數中儲存的憑證。它會使用 IncludeChain 參數來包含信任鏈結 (包括根授權單位) 中的所有簽章,也會使用 TimeStampServer 參數,將時間戳記新增到簽章。如此可避免指令碼在憑證過期時失敗。</maml:para> <maml:para></maml:para> <maml:para></maml:para> <maml:para></maml:para> <maml:para></maml:para> </dev:remarks> <command:commandLines> <command:commandLine> <command:commandText></command:commandText> </command:commandLine> </command:commandLines> </command:example> </command:examples> <!-- Link section --> <maml:relatedLinks> <maml:navigationLink> <maml:linkText>Online version:</maml:linkText> <maml:uri>http://go.microsoft.com/fwlink/?LinkID=113391</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>about_Signing</maml:linkText> <maml:uri /> </maml:navigationLink> <maml:navigationLink> <maml:linkText>about_Execution_Policies</maml:linkText> <maml:uri /> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Get-AuthenticodeSignature</maml:linkText> <maml:uri /> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Get-PfxCertificate</maml:linkText> <maml:uri /> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Get-ExecutionPolicy</maml:linkText> <maml:uri /> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Set-ExecutionPolicy</maml:linkText> <maml:uri /> </maml:navigationLink> </maml:relatedLinks> </command:command> <!-- v 1.1.0.9 --> <command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10"> <command:details> <command:name> Set-ExecutionPolicy </command:name> <maml:description> <maml:para>變更 Windows PowerShell 執行原則的使用者喜好設定。</maml:para> </maml:description> <maml:copyright> <maml:para></maml:para> </maml:copyright> <command:verb>Set</command:verb> <command:noun>ExecutionPolicy</command:noun> <dev:version></dev:version> </command:details> <maml:description> <maml:para>Set-ExecutionPolicy 會變更 Windows PowerShell 執行原則的使用者喜好設定。 若要在 Windows Vista、Windows Server 2008 和更新版的 Windows 上執行此命令,您必須利用 [以系統管理員身分執行] 選項啟動 Windows PowerShell,即使您是該電腦 Administrators 群組的成員也一樣。 執行原則是 Windows PowerShell 安全性策略的一部分。它決定您可否載入組態檔 (包括 Windows PowerShell 設定檔) 及執行指令碼,同時也決定哪些指令碼 (如果有的話) 必須先經過數位簽署才能執行。 如需詳細資訊,請參閱 about_Execution_Policies。</maml:para> </maml:description> <!-- Cmdlet syntax section--> <command:syntax> <command:syntaxItem> <maml:name>Set-ExecutionPolicy</maml:name> <command:parameter required="true" variableLength="false" globbing="false" pipelineInput="true (ByValue)" position="1"> <maml:name>ExecutionPolicy</maml:name> <maml:description> <maml:para>為殼層指定新的執行原則。參數名稱 ("Name") 為選擇項。 有效的值包括: -- Restricted:不載入組態檔或執行指令碼。預設值為 "Restricted"。 -- AllSigned:所有的指令碼和組態檔都需經過受信任的發行者簽署,包括本機電腦上撰寫的指令碼在內。 -- RemoteSigned:從網際網路下載的指令碼和組態檔都需經過受信任的發行者簽署。 -- Unrestricted:載入所有的組態檔且執行所有的指令碼。如果執行的指令碼是從網際網路下載而未經簽署,執行前將提示您權限有問題。 -- Bypass:不會封鎖任何項目,而且沒有警告或提示。 -- Undefined:從目前的範圍中移除目前所指派的執行原則。這個參數不會移除在群組原則範圍中設定的執行原則。 </maml:para> </maml:description> <command:parameterValueGroup> <command:parameterValue required="false" variableLength="false">Unrestricted</command:parameterValue> <command:parameterValue required="false" variableLength="false">RemoteSigned</command:parameterValue> <command:parameterValue required="false" variableLength="false">AllSigned</command:parameterValue> <command:parameterValue required="false" variableLength="false">Restricted</command:parameterValue> <command:parameterValue required="false" variableLength="false">Default</command:parameterValue> <command:parameterValue required="false" variableLength="false">Bypass</command:parameterValue> <command:parameterValue required="false" variableLength="false">Undefined</command:parameterValue> </command:parameterValueGroup> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="true (ByPropertyName)" position="2"> <maml:name>Scope</maml:name> <maml:description> <maml:para>指定執行原則的範圍。預設值為 LocalMachine。 有效的值包括: -- Process:執行原則只會影響目前的 Windows PowerShell 處理序。 -- CurrentUser:執行原則只會影響目前的使用者。 -- LocalMachine:執行原則會影響電腦的所有使用者。 若要從特定範圍中移除執行原則,請將該範圍的執行原則設定為 Undefined。</maml:para> </maml:description> <command:parameterValueGroup> <command:parameterValue required="false" variableLength="false">Process</command:parameterValue> <command:parameterValue required="false" variableLength="false">CurrentUser</command:parameterValue> <command:parameterValue required="false" variableLength="false">LocalMachine</command:parameterValue> <command:parameterValue required="false" variableLength="false">UserPolicy</command:parameterValue> <command:parameterValue required="false" variableLength="false">MachinePolicy</command:parameterValue> </command:parameterValueGroup> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named"> <maml:name>Force</maml:name> <maml:description> <maml:para>抑制所有提示。根據預設,每當您變更執行原則時,Set-ExecutionPolicy 就會顯示警告。</maml:para> </maml:description> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="false" position="named"> <maml:name>Confirm</maml:name> <maml:description> <maml:para>在執行命令前先提示確認。</maml:para> </maml:description> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="false" position="named"> <maml:name>WhatIf</maml:name> <maml:description> <maml:para>說明執行命令時將會發生何種情況,但不會實際執行命令。</maml:para> </maml:description> </command:parameter> </command:syntaxItem> </command:syntax> <!-- Cmdlet parameter section --> <command:parameters> <command:parameter required="true" variableLength="false" globbing="false" pipelineInput="true (ByValue)" position="1"> <maml:name>ExecutionPolicy</maml:name> <maml:description> <maml:para>為殼層指定新的執行原則。參數名稱 ("Name") 為選擇項。 有效的值包括: -- Restricted:不載入組態檔或執行指令碼。預設值為 "Restricted"。 -- AllSigned:所有的指令碼和組態檔都需經過受信任的發行者簽署,包括本機電腦上撰寫的指令碼在內。 -- RemoteSigned:從網際網路下載的指令碼和組態檔都需經過受信任的發行者簽署。 -- Unrestricted:載入所有的組態檔且執行所有的指令碼。如果執行的指令碼是從網際網路下載而未經簽署,執行前將提示您權限有問題。 -- Bypass:不會封鎖任何項目,而且沒有警告或提示。 -- Undefined:從目前的範圍中移除目前所指派的執行原則。這個參數不會移除在群組原則範圍中設定的執行原則。 </maml:para> </maml:description> <command:parameterValue required="true" variableLength="false">ExecutionPolicy</command:parameterValue> <dev:type> <maml:name>ExecutionPolicy</maml:name> <maml:uri /> </dev:type> <dev:defaultValue></dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named"> <maml:name>Force</maml:name> <maml:description> <maml:para>抑制所有提示。根據預設,每當您變更執行原則時,Set-ExecutionPolicy 就會顯示警告。</maml:para> </maml:description> <command:parameterValue required="false" variableLength="false">SwitchParameter</command:parameterValue> <dev:type> <maml:name>SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue></dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="false" globbing="false" pipelineInput="true (ByPropertyName)" position="2"> <maml:name>Scope</maml:name> <maml:description> <maml:para>指定執行原則的範圍。預設值為 LocalMachine。 有效的值包括: -- Process:執行原則只會影響目前的 Windows PowerShell 處理序。 -- CurrentUser:執行原則只會影響目前的使用者。 -- LocalMachine:執行原則會影響電腦的所有使用者。 若要從特定範圍中移除執行原則,請將該範圍的執行原則設定為 Undefined。</maml:para> </maml:description> <command:parameterValue required="true" variableLength="false">ExecutionPolicyScope</command:parameterValue> <dev:type> <maml:name>ExecutionPolicyScope</maml:name> <maml:uri /> </dev:type> <dev:defaultValue>LocalMachine</dev:defaultValue> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="false" position="named"> <maml:name>Confirm</maml:name> <maml:description> <maml:para>在執行命令前先提示確認。</maml:para> </maml:description> <command:parameterValue required="false" variableLength="false">SwitchParameter</command:parameterValue> <dev:type> <maml:name>SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue /> </command:parameter> <command:parameter required="false" variableLength="true" globbing="false" pipelineInput="false" position="named"> <maml:name>WhatIf</maml:name> <maml:description> <maml:para>說明執行命令時將會發生何種情況,但不會實際執行命令。</maml:para> </maml:description> <command:parameterValue required="false" variableLength="false">SwitchParameter</command:parameterValue> <dev:type> <maml:name>SwitchParameter</maml:name> <maml:uri /> </dev:type> <dev:defaultValue /> </command:parameter> </command:parameters> <!-- Input - Output section--> <command:inputTypes> <command:inputType> <dev:type> <maml:name>Microsoft.PowerShell.ExecutionPolicy 或 System.String</maml:name> <maml:uri /> <maml:description /> </dev:type> <maml:description> <maml:para> <!-- description --> 您可經由管道將執行原則物件或包含執行原則名稱的字串輸出至 Set-ExecutionPolicy。 </maml:para> </maml:description> </command:inputType> </command:inputTypes> <command:returnValues> <command:returnValue> <dev:type> <maml:name>無</maml:name> <maml:uri /> <maml:description /> </dev:type> <maml:description> <maml:para> <!-- description --> 這個 Cmdlet 不會傳回任何輸出。 </maml:para> </maml:description> </command:returnValue> </command:returnValues> <!-- Error section--> <command:terminatingErrors /> <command:nonTerminatingErrors /> <!-- Notes section --> <maml:alertSet> <maml:title></maml:title> <maml:alert> <maml:para> 當您使用 Set-ExecutionPolicy 時,新的使用者喜好設定就會寫入登錄,而且除非您加以變更,否則將一直保持不變。 不過,如果電腦或使用者啟用了「開啟指令碼執行」群組原則,使用者偏好設定雖然寫入登錄,但是不會生效,而且 Windows PowerShell 也會顯示訊息說明有衝突。您無法使用 Set-ExecutionPolicy 來覆寫群組原則,即便使用者喜好設定較該原則更具限制性。 </maml:para> </maml:alert> <maml:alert> <maml:para></maml:para> </maml:alert> </maml:alertSet> <!-- Example section --> <command:examples> <command:example> <maml:title> -------------------------- 範例 1 -------------------------- </maml:title> <maml:introduction> <maml:para>C:\PS></maml:para> </maml:introduction> <dev:code> set-executionpolicy remotesigned </dev:code> <dev:remarks> <maml:para>描述</maml:para> <maml:para>-----------</maml:para> <maml:para>這個命令將殼層執行原則的使用者偏好設定設為 RemoteSigned。</maml:para> <maml:para></maml:para> <maml:para></maml:para> <maml:para></maml:para> <maml:para></maml:para> </dev:remarks> <command:commandLines> <command:commandLine> <command:commandText></command:commandText> </command:commandLine> </command:commandLines> </command:example> <command:example> <maml:title> -------------------------- 範例 2 -------------------------- </maml:title> <maml:introduction> <maml:para>C:\PS></maml:para> </maml:introduction> <dev:code> Set-ExecutionPolicy Restricted Set-ExecutionPolicy : Windows PowerShell updated your local preference successfully, but the setting is overridden by the group policy applied to your system. Due to the override, your shell will retain its current effective execution policy of "AllSigned". Contact your group policy administrator for more information. At line:1 char:20 + set-executionpolicy <<<< restricted </dev:code> <dev:remarks> <maml:para>描述</maml:para> <maml:para>-----------</maml:para> <maml:para>這個命令嘗試將殼層執行原則設定為 "Restricted"。"Restricted" 設定雖然寫入登錄,但是因為與群組原則衝突,所以不會生效,即便較該原則更具限制性,也是如此。</maml:para> <maml:para></maml:para> <maml:para></maml:para> <maml:para></maml:para> <maml:para></maml:para> </dev:remarks> <command:commandLines> <command:commandLine> <command:commandText></command:commandText> </command:commandLine> </command:commandLines> </command:example> <command:example> <maml:title> -------------------------- 範例 3 -------------------------- </maml:title> <maml:introduction> <maml:para>C:\PS></maml:para> </maml:introduction> <dev:code> invoke-command -computername Server01 -scriptblock {get-executionpolicy} | set-executionpolicy -force </dev:code> <dev:remarks> <maml:para>描述</maml:para> <maml:para>-----------</maml:para> <maml:para>此命令從遠端電腦取得執行原則,並將其套用至本機電腦。 此命令是使用 Invoke-Command Cmdlet 將命令傳送至遠端電腦。因為您可以經由管道將 ExecutionPolicy (Microsoft.PowerShell.ExecutionPolicy) 物件輸出至 Set-ExecutionPolicy,所以 Set-ExecutionPolicy 命令不需要 ExecutionPolicy 參數。 此命令具有 Force 參數,以便抑制使用者提示。</maml:para> <maml:para></maml:para> <maml:para></maml:para> <maml:para></maml:para> <maml:para></maml:para> </dev:remarks> <command:commandLines> <command:commandLine> <command:commandText></command:commandText> </command:commandLine> </command:commandLines> </command:example> <command:example> <maml:title> -------------------------- 範例 4 -------------------------- </maml:title> <maml:introduction> <maml:para>C:\PS></maml:para> </maml:introduction> <dev:code> set-executionpolicy -scope CurrentUser -executionPolicy AllSigned -force C:\PS> get-executionpolicy -list Scope ExecutionPolicy ----- --------------- MachinePolicy Undefined UserPolicy Undefined Process Undefined CurrentUser AllSigned LocalMachine RemoteSigned C:\PS> get-executionpolicy AllSigned </dev:code> <dev:remarks> <maml:para>描述</maml:para> <maml:para>-----------</maml:para> <maml:para>這個範例會示範如何設定特定範圍的執行原則。 第一個命令會使用 Set-ExecutionPolicy Cmdlet,針對目前的使用者設定執行原則 AllSigned。它會使用 Force 參數來抑制使用者提示。 第二個命令會使用 Get-ExecutionPolicy 的 List 參數來取得每個範圍中設定的執行原則。結果顯示,針對目前使用者所設定的執行原則與針對所有電腦使用者所設定的執行原則不同。 第三個命令會使用不含參數的 Get-ExecutionPolicy Cmdlet 來取得本機電腦上目前使用者的有效執行原則。結果確認,針對目前使用者所設定的執行原則優先順序高於針對所有用者所設定的執行原則。</maml:para> <maml:para></maml:para> <maml:para></maml:para> <maml:para></maml:para> <maml:para></maml:para> </dev:remarks> <command:commandLines> <command:commandLine> <command:commandText></command:commandText> </command:commandLine> </command:commandLines> </command:example> <command:example> <maml:title> -------------------------- 範例 5 -------------------------- </maml:title> <maml:introduction> <maml:para>C:\PS></maml:para> </maml:introduction> <dev:code> set-executionpolicy -scope CurrentUser -executionPolicy Undefined </dev:code> <dev:remarks> <maml:para>描述</maml:para> <maml:para>-----------</maml:para> <maml:para>這個命令會使用執行原則值 Undefined 來有效地移除針對目前使用者範圍所設定的執行原則。因此,在群組原則或在 LocalMachine (所有使用者) 範圍中設定的執行原則都是有效的。 如果您將所有範圍中的執行原則設定為 Undefined,但並未設定群組原則,預設執行原則 Restricted 就會針對所有電腦使用者生效。</maml:para> <maml:para></maml:para> <maml:para></maml:para> <maml:para></maml:para> <maml:para></maml:para> </dev:remarks> <command:commandLines> <command:commandLine> <command:commandText></command:commandText> </command:commandLine> </command:commandLines> </command:example> </command:examples> <!-- Link section --> <maml:relatedLinks> <maml:navigationLink> <maml:linkText>Online version:</maml:linkText> <maml:uri>http://go.microsoft.com/fwlink/?LinkID=113394</maml:uri> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Get-ExecutionPolicy</maml:linkText> <maml:uri /> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Set-AuthenticodeSignature</maml:linkText> <maml:uri /> </maml:navigationLink> <maml:navigationLink> <maml:linkText>Get-AuthenticodeSignature</maml:linkText> <maml:uri /> </maml:navigationLink> <maml:navigationLink> <maml:linkText>about_Execution_Policies</maml:linkText> <maml:uri /> </maml:navigationLink> <maml:navigationLink> <maml:linkText>about_Signing</maml:linkText> <maml:uri /> </maml:navigationLink> </maml:relatedLinks> </command:command> <!-- v 1.1.0.9 --> <providerHelp> <Name> Certificate </Name> <Drives> <Para>Cert:</Para> </Drives> <Synopsis> 可讓您從 Windows PowerShell 中存取 X.509 憑證存放區和憑證。 </Synopsis> <DetailedDescription> <para>Windows PowerShell 安全性策略支援使用 Authenticode 簽章來簽署使用 X.509 編碼之數位公開金鑰憑證的指令碼。Windows PowerShell 無意提供完備的簽署功能,提供這些功能只是為了讓使用者可以簽署指令碼,並使 Windows PowerShell 能夠辨識已經簽署和未經簽署的指令碼,以及判斷指令碼是否來自網際網路。 Windows PowerShell Certificate 提供者可讓您瀏覽憑證命名空間,並檢視憑證存放區和憑證。它也能讓您複製、移動和刪除憑證與憑證存放區,並開啟 Microsoft Management Console (MMC) 的憑證嵌入式管理單元。 Certificate 提供者會在 Windows PowerShell 中,將憑證命名空間公開為 Cert: 磁碟機。Cert: 磁碟機有下列三個層級: -- 存放區位置 (Microsoft.PowerShell.Commands.X509StoreLocation):這是目前使用者及所有使用者之憑證群組的高層容器。每個系統都有 CurrentUser 和 LocalMachine (所有使用者) 存放區位置。 -- 憑證存放區 (System.Security.Cryptography.X509Certificates.X509Store):這是儲存及管理憑證的實體存放區。 -- X.509 憑證 (System.Security.Cryptography.X509Certificates.X509Certificate2):其中的每一個都代表電腦中的 X.509 憑證。識別憑證的方式是依據其指紋。 Windows PowerShell Certificate 提供者支援 Set-Location、Get-Location、Get-Item、Get-ChildItem 和 Invoke-Item Cmdlet。 此外,Windows PowerShell 安全性嵌入式管理單元 (Microsoft.PowerShell.Security),包括 Certificate 提供者,也加入了許多嵌入式管理單元,可用來取得和設定 Authenticode 簽章,以及取得憑證。如需安全性嵌入式管理單元中的 Cmdlet 清單,請輸入 "get-command -module *security"。</para> </DetailedDescription> <Capabilities> <para></para> </Capabilities> <Filters> <para></para> </Filters> <Notes> </Notes> <Tasks> <Task> <Title> 瀏覽 Cert: 磁碟機 </Title> <Description> <para></para> </Description> <Examples> <Example> <Title> -------------------------- 範例 1 -------------------------- </Title> <Introduction> <para>這個命令會使用 Set-Location Cmdlet,將目前位置變更為 Cert: 磁碟機。</para> </Introduction> <Code> set-location cert: </Code> <Remarks> <para></para> </Remarks> </Example> <Example> <Title> -------------------------- 範例 2 -------------------------- </Title> <Introduction> <para>這個命令會使用 Set-Location 命令,將目前位置變更為 LocalMachine 存放區位置中的根憑證存放區。請使用反斜線 (\) 或斜線 (/) 來指出 Cert: 磁碟機的層級。</para> </Introduction> <Code> set-location -path LocalMachine\Root </Code> <Remarks> <para>如果您目前不在 Cert: 磁碟機中,請在路徑開頭加上磁碟機名稱。</para> </Remarks> </Example> </Examples> </Task> <Task> <Title> 顯示 Cert: 磁碟機的內容 </Title> <Description> <para></para> </Description> <Examples> <Example> <Title> -------------------------- 範例 1 -------------------------- </Title> <Introduction> <para>這個命令會使用 Get-ChildItem Cmdlet 來顯示 CurrentUser 憑證存放區位置中的憑證存放區。</para> </Introduction> <Code> get-childitem -path cert:\CurrentUser </Code> <Remarks> <para>如果您目前在 Cert: 磁碟機上,則可省略磁碟機名稱。</para> </Remarks> </Example> <Example> <Title> -------------------------- 範例 2 -------------------------- </Title> <Introduction> <para>這個命令會使用 Get-ChildItem Cmdlet 來顯示 My 憑證存放區中的憑證。</para> </Introduction> <Code> get-childitem -path cert:\CurrentUser\My </Code> <Remarks> <para>如果您目前在 Cert: 磁碟機上,則可省略磁碟機名稱。</para> </Remarks> </Example> <Example> <Title> -------------------------- 範例 3 -------------------------- </Title> <Introduction> <para>這個命令會使用 Get-Item Cmdlet 取得 "My" 憑證存放區,並使用 Format-List 的 Property 參數搭配萬用字元 (*),以顯示存放區的所有屬性。</para> </Introduction> <Code> get-item -path cert:\CurrentUser\My | format-list * </Code> <Remarks> <para></para> </Remarks> </Example> <Example> <Title> -------------------------- 範例 4 -------------------------- </Title> <Introduction> <para>這個命令會取得憑證,並顯示其所有屬性。它會使用 Get-ChildItem Cmdlet 取得憑證,並使用 Format-List 的 Property 參數搭配萬用字元 (*),以顯示憑證的所有屬性。 識別憑證的方式是依據其指紋。</para> </Introduction> <Code> get-childitem -path cert:\CurrentUser\my\6B8223358119BB08840DEE50FD8AF9EA776CE66B | format-list -property * </Code> <Remarks> <para></para> </Remarks> </Example> <Example> <Title> -------------------------- 範例 5 -------------------------- </Title> <Introduction> <para>這個命令會使用 Get-ChildItem Cmdlet 取得電腦中的所有憑證,並且使用其 CodeSigningCert 動態參數,只擷取持有程式碼簽署授權的憑證。</para> </Introduction> <Code> get-childitem -path * -codesigningcert -recurse </Code> <Remarks> <para></para> </Remarks> </Example> </Examples> </Task> <Task> <Title> 開啟憑證 MMC 嵌入式管理單元 </Title> <Description> <para></para> </Description> <Examples> <Example> <Title> -------------------------- 範例 1 -------------------------- </Title> <Introduction> <para>這個命令開啟憑證 MMC 嵌入式管理單元來管理指定的憑證。</para> </Introduction> <Code> invoke item cert:\CurrentUser\my\6B8223358119BB08840DEE50FD8AF9EA776CE66B </Code> <Remarks> <para></para> </Remarks> </Example> </Examples> </Task> </Tasks> <DynamicParameters> <DynamicParameter> <Name>CodeSigningCert</Name> <CmdletSupported>Get-Item, Get-ChildItem</CmdletSupported> <Type> <Name>System.Management.Automation.SwitchParameter</Name> </Type> <Description>只擷取那些具有程式碼簽署授權的憑證。</Description> <PossibleValues> <PossibleValue> <Value></Value> <Description> <para></para> </Description> </PossibleValue> </PossibleValues> </DynamicParameter> </DynamicParameters> <RelatedLinks> <navigationLink> <linkText>about_Providers</linkText> <uri /> </navigationLink> <navigationLink> <linkText>about_Signing</linkText> <uri /> </navigationLink> <navigationLink> <linkText>Get-AuthenticodeSignature</linkText> <uri /> </navigationLink> <navigationLink> <linkText>Set-AuthenticodeSignature</linkText> <uri /> </navigationLink> <navigationLink> <linkText>Get-PfxCertificate</linkText> <uri /> </navigationLink> </RelatedLinks> </providerHelp> </helpItems>