|
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>
Add-History
</command:name>
<maml:description>
<maml:para>附加項目到工作階段歷程記錄。</maml:para>
</maml:description>
<maml:copyright>
<maml:para></maml:para>
</maml:copyright>
<command:verb>Add</command:verb>
<command:noun>History</command:noun>
<dev:version></dev:version>
</command:details>
<maml:description>
<maml:para>Add-History Cmdlet 會在工作階段歷程記錄的結尾新增項目,而工作階段歷程記錄就是在目前工作階段期間所輸入命令的清單。
您可以使用 Get-History Cmdlet 取得這些命令並將它們傳遞到 Add-History,也可以將這些命令匯出到 CSV 或 XML 檔案、匯入這些命令,然後將匯入的檔案傳遞到 Add-History。您可以使用這個 Cmdlet 將特定命令新增到歷程記錄中,或是建立單一個歷程記錄檔案來包含一個以上工作階段中的命令。</maml:para>
</maml:description>
<!-- Cmdlet syntax section-->
<command:syntax>
<command:syntaxItem>
<maml:name>Add-History</maml:name>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="true (ByValue)" position="1">
<maml:name>InputObject</maml:name>
<maml:description>
<maml:para>將指定的 HistoryInfo 物件新增至工作階段歷程記錄。使用此參數可將 Get-History、Import-Clixml 或 Import-Csv 傳回的 HistoryInfo 物件提交至 Add-History。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="true">PSObject[]</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:syntaxItem>
</command:syntax>
<!-- Cmdlet parameter section -->
<command:parameters>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="true (ByValue)" position="1">
<maml:name>InputObject</maml:name>
<maml:description>
<maml:para>將指定的 HistoryInfo 物件新增至工作階段歷程記錄。使用此參數可將 Get-History、Import-Clixml 或 Import-Csv 傳回的 HistoryInfo 物件提交至 Add-History。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="true">PSObject[]</command:parameterValue>
<dev:type>
<maml:name>PSObject[]</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:parameters>
<!-- Input - Output section-->
<command:inputTypes>
<command:inputType>
<dev:type>
<maml:name>Microsoft.PowerShell.Commands.HistoryInfo</maml:name>
<maml:uri />
<maml:description />
</dev:type>
<maml:description>
<maml:para>
<!-- description -->
您可經由管道將 HistoryInfo 物件輸出至 Add-History。
</maml:para>
</maml:description>
</command:inputType>
</command:inputTypes>
<command:returnValues>
<command:returnValue>
<dev:type>
<maml:name>無或 Microsoft.PowerShell.Commands.HistoryInfo</maml:name>
<maml:uri />
<maml:description />
</dev:type>
<maml:description>
<maml:para>
<!-- description -->
當您使用 PassThru 參數時,Add-History 就會產生 HistoryInfo 物件。否則,這個 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>
工作階段歷程記錄是在工作階段期間所輸入命令的清單以及識別碼。工作階段歷程記錄代表執行的順序、狀態,以及命令的開始和結束時間。每當您輸入一個命令,Windows PowerShell 便會將其新增至歷程記錄,讓您可以重複使用。如需工作階段歷程記錄的詳細資訊,請參閱 about_History。
若要指定要新增到歷程記錄的命令,請使用 InputObject 參數。Add-History 命令只接受 HistoryInfo 物件,例如 Get-History 為每個命令產生的物件。您不能將路徑、檔案名稱或是命令清單傳遞到這個命令。
您可以使用 -InputObject 參數將 HistoryInfo 物件的檔案傳遞給 Add-History。若要這樣做,請使用 Export-Csv 或 Export-Clixml,將 Get-History 命令的結果匯出至檔案,然後使用 Import-Csv 或 Import-Clixml 來匯入該檔案。然後,您就可以透過管線或是使用變數,將已匯入 HistoryInfo 物件的檔案傳遞到 Add-History。如需詳細資訊,請參閱範例。
傳遞到 Add-History 的 HistoryInfo 物件檔案必須包含類型資訊、欄標題,以及這些 HistoryInfo 物件的所有屬性。若您要將這些物件傳回 Add-History,請不要使用 Export-Csv 的 NoTypeInformation 參數,也不要刪除檔案中的類型資訊、欄標題或任何欄位。
若要編輯工作階段歷程記錄,請依序將工作階段匯出到 CSV 或 XML 檔案、編輯此檔案、匯入此檔案,然後使用 Add-History 將它附加到目前的工作階段歷程記錄。
</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-history | export-csv c:\testing\history.csv
C:\PS>import-csv history.csv | add-history </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這些命令會將某個 Windows PowerShell 工作階段期間所輸入的命令新增到不同 Windows PowerShell 工作階段的歷程記錄。第一個命令會取得代表歷程記錄中命令的物件,然後將它們匯出到 History.csv 檔案。第二個命令則是從另一個工作階段的命令列中輸入。它會使用 Import-Csv Cmdlet 匯入此 History.csv 檔案中的物件。管線運算子會將這些物件傳遞到 Add-History Cmdlet,並由後者將代表 History.csv 檔案中命令的物件新增到目前的工作階段歷程記錄。</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>
import-clixml c:\temp\history.xml | add-history -passthru | foreach-object {invoke-history} </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個命令會匯入 History.xml 檔案中的命令、將這些命令新增至目前的工作階段歷程記錄,接著執行合併歷程記錄中的命令。
第一個命令會使用 Import-Clixml 命令,匯入已匯出到 History.xml 檔案的命令歷程記錄。管線運算子 (|) 會將這些命令傳遞到 Add-History 參數,並由後者將命令新增到目前的工作階段歷程記錄。PassThru 參數會沿著管線向下傳遞代表所新增之命令的物件。
接著,這個命令會使用 ForEach-Object Cmdlet 將 Invoke-History 命令套用至合併歷程記錄中的每個命令。Invoke-History 命令會格式化成指令碼區塊 (以大括號 ({}) 括住),因為即使只套用一個命令,ForEach-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:example>
<maml:title>
-------------------------- 範例 3 --------------------------
</maml:title>
<maml:introduction>
<maml:para>C:\PS></maml:para>
</maml:introduction>
<dev:code>
get-history -id 5 -count 5 | add-history </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個命令會將歷程記錄中的前 5 個命令新增到歷程記錄清單的結尾。它會使用 Get-History Cmdlet 取得到命令 5 為止的五個命令。管線運算子 (|) 會將這些命令傳遞到 Add-History Cmdlet,並由此 Cmdlet 將它們附加至目前的歷程記錄。雖然 Add-History 命令並不包含任何參數,不過 Windows PowerShell 會讓透過管線傳遞的物件與 InputObject 參數產生關聯。</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>
$a = import-csv c:\testing\history.csv
C:\PS>add-history -inputobject $a -passthru </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這些命令會將 History.csv 檔案中的命令新增到目前的工作階段歷程記錄。第一個命令會使用 Import-Csv Cmdlet 匯入 History.csv 檔案中的命令,然後將其內容存放到變數 $a。第二個命令會使用 Add-History Cmdlet,將 History.csv 中的命令新增至目前的工作階段歷程記錄。它會使用 InputObject 參數指定 $a 變數,並使用 PassThru 參數產生要顯示在命令列中的物件。如果沒有使用 PassThru 參數,Add-History 就不會產生任何要顯示的輸出。</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>
add-history -inputobject (import-clixml c:\temp\history01.xml) </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個命令會將 History01.xml 檔案中的命令新增到目前的工作階段歷程記錄。它會使用 InputObject 參數將括號中命令的結果傳遞到 Add-History。括號中的命令 (優先執行) 會將 History01.xml 檔案匯入 Windows PowerShell。然後,Add-History 會將檔案中的命令新增至工作階段歷程記錄。</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=113279</maml:uri>
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>about_History</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Get-History</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Invoke-History</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Clear-History</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>
Add-PSSnapin
</command:name>
<maml:description>
<maml:para>將一個或多個 Windows PowerShell 嵌入式管理單元新增至目前的工作階段。</maml:para>
</maml:description>
<maml:copyright>
<maml:para></maml:para>
</maml:copyright>
<command:verb>Add</command:verb>
<command:noun>PSSnapin</command:noun>
<dev:version></dev:version>
</command:details>
<maml:description>
<maml:para>Add-PSSnapin Cmdlet 會將已註冊的 Windows PowerShell 嵌入式管理單元新增至目前的工作階段。新增這些嵌入式管理單元之後,您就可以在目前的工作階段中,使用這些嵌入式管理單元支援的 Cmdlet 和提供者。
若要將嵌入式管理單元新增至未來所有的 Windows PowerShell 工作階段,請將 Add-PSSnapin 命令新增至 Windows PowerShell 設定檔。如需詳細資訊,請參閱 about_Profiles。</maml:para>
</maml:description>
<!-- Cmdlet syntax section-->
<command:syntax>
<command:syntaxItem>
<maml:name>Add-PSSnapin</maml:name>
<command:parameter required="true" variableLength="true" globbing="false" pipelineInput="true (ByPropertyName)" position="1">
<maml:name>Name</maml:name>
<maml:description>
<maml:para>指定嵌入式管理單元的名稱 (這是 Name,而不是 AssemblyName 或 ModuleName)。
若要尋找系統上已註冊嵌入式管理單元的名稱,請輸入:"get-pssnapin -registered"。</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:syntaxItem>
</command:syntax>
<!-- Cmdlet parameter section -->
<command:parameters>
<command:parameter required="true" variableLength="true" globbing="false" pipelineInput="true (ByPropertyName)" position="1">
<maml:name>Name</maml:name>
<maml:description>
<maml:para>指定嵌入式管理單元的名稱 (這是 Name,而不是 AssemblyName 或 ModuleName)。
若要尋找系統上已註冊嵌入式管理單元的名稱,請輸入:"get-pssnapin -registered"。</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: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 -->
您無法經由管道將物件輸出至 Add-PSSnapin。
</maml:para>
</maml:description>
</command:inputType>
</command:inputTypes>
<command:returnValues>
<command:returnValue>
<dev:type>
<maml:name>無或 System.Management.Automation.PSSnapInInfo</maml:name>
<maml:uri />
<maml:description />
</dev:type>
<maml:description>
<maml:para>
<!-- description -->
當您使用 PassThru 參數時,Add-PSSnapin 會傳回代表嵌入式管理單元的 PSSnapInInfo 物件。否則,這個 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>
如需 Windows PowerShell 中嵌入式管理單元的詳細資訊,請參閱 about_PSSnapins。如需如何建立 Windows PowerShell 嵌入式管理單元的詳細資訊,請參閱 MSDN (Microsoft Developer Network) Library 中的<如何建立 Windows PowerShell 嵌入式管理單元>(英文),網址為:http://go.microsoft.com/fwlink/?LinkId=144762。
Add-PSSnapin 只會在目前的工作階段中新增嵌入式管理單元。若要將嵌入式管理單元新增至所有 Windows PowerShell 工作階段,請將此 Cmdlet 新增至 Windows PowerShell 設定檔。如需詳細資訊,請參閱 about_Profiles。
您可以新增任何已經使用 Microsoft .NET Framework 安裝公用程式完成註冊的 Windows PowerShell 嵌入式管理單元。如需詳細資訊,請參閱 MSDN Library 中的<如何註冊 Cmdlet、提供者和主機應用程式>(英文),網址為:http://go.microsoft.com/fwlink/?LinkID=143619。
若要取得電腦已註冊的嵌入式管理單元清單,請輸入 "get-pssnapin -registered"。
在新增嵌入式管理單元之前,Add-PSSnapin 會先檢查嵌入式管理單元的版本,確認是否與目前的 Windows PowerShell 版本相容。如果嵌入式管理單元版本檢查失敗,Windows PowerShell 就會報告錯誤。
</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>
add-PSSnapIn Microsoft.Exchange, Microsoft.Windows.AD </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個命令會將 Microsoft Exchange 和 Active Directory 嵌入式管理單元新增至目前的工作階段。</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-pssnapin -registered | add-pssnapin -passthru </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個命令會將所有已註冊的 Windows PowerShell 嵌入式管理單元新增至工作階段。它會使用 Get-PSSnapin Cmdlet 搭配 Registered 參數,取得代表每個已註冊之嵌入式管理單元的物件。管線運算子 (|) 會將結果傳遞到 Add-PSSnapin,並由其將這些物件新增至工作階段。PassThru 參數會傳回代表每個新增之嵌入式管理單元的物件。</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-pssnapin </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>在這個範例中,會示範在系統上註冊嵌入式管理單元,然後將它新增至工作階段的程序。範例中使用 ManagementFeatures,這是在 ManagementCmdlets.dll 檔案中實作的虛構嵌入式管理單元。
第一個命令會取得已新增至目前工作階段的嵌入式管理單元,包括與 Windows PowerShell 一併安裝的嵌入式管理單元。在這個範例中,不會傳回 ManagementFeatures。這表示此嵌入式管理單元尚未新增至工作階段。
get-pssnapin
第二個命令會取得在系統上已註冊的嵌入式管理單元 (包括已新增至工作階段的嵌入式管理單元),但不包含與 Windows PowerShell 一併安裝的嵌入式管理單元。
get-pssnapin -registered
在此例中,命令不會傳回任何嵌入式管理單元。這表示 ManagementFeatures 嵌入式管理單元尚未在系統上註冊。
第三個命令會建立別名 "installutil",表示 .NET Framework 工具 InstallUtil 的路徑。
set-alias installutil $env:windir\Microsoft.NET\Framework\v2.0.50727\installutil.exe
第四個命令會使用 InstallUtil 工具註冊此嵌入式管理單元,並指定 ManagementCmdlets.dll (此嵌入式管理單元的檔案名稱或「模組名稱」) 的路徑。
installutil C:\Dev\Management\ManagementCmdlets.dll
第五個命令與第二個命令相同。現在,您可以使用它來確認是否已註冊 ManagementCmdlets 嵌入式管理單元。
get-pssnapin -registered
第六個命令會使用 Add-PSSnapin Cmdlet 將 ManagementFeatures 嵌入式管理單元新增至工作階段,並指定嵌入式管理單元 ManagementFeatures 的名稱,而不是檔案名稱。
add-pssnapin ManagementFeatures
第七個命令會使用 Get-Command Cmdlet 的 Module 參數,確認此嵌入式管理單元是否已新增至工作階段。它會依照嵌入式管理單元或模組,顯示已新增至工作階段的項目。
get-command -module ManagementFeatures
您也可以使用 Get-Command 所傳回物件的 PSSnapin 屬性,尋找 Cmdlet 的來源嵌入式管理單元或模組。第八個命令會使用點標記法,尋找 Set-Alias 命令的 PSSnapin 屬性值。
(get-command set-alias).pssnapin
</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=113281</maml:uri>
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Get-PSSnapin</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Remove-PSSnapin</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>about_Profiles</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>
Clear-History
</command:name>
<maml:description>
<maml:para>刪除命令歷程記錄中的項目。</maml:para>
</maml:description>
<maml:copyright>
<maml:para></maml:para>
</maml:copyright>
<command:verb>Clear</command:verb>
<command:noun>History</command:noun>
<dev:version></dev:version>
</command:details>
<maml:description>
<maml:para>Clear-History Cmdlet 會從命令歷程記錄 (也就是在目前工作階段期間所輸入命令的清單) 刪除命令。
如果沒有使用參數,Clear-History 就會刪除工作階段歷程記錄中的所有命令,不過您可以使用 Clear-History 的參數來刪除選取的命令。</maml:para>
</maml:description>
<!-- Cmdlet syntax section-->
<command:syntax>
<command:syntaxItem>
<maml:name>Clear-History</maml:name>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="false" position="1">
<maml:name>Id</maml:name>
<maml:description>
<maml:para>刪除具有指定之歷程記錄識別碼的命令。
若要尋找命令的歷程記錄識別碼,請使用 Get-History。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="true">Int32[]</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="2">
<maml:name>Count</maml:name>
<maml:description>
<maml:para>由歷程記錄中最舊的項目開始,清除指定的項目數目。
如果在相同的命令中使用 Count 和 Id 參數,此 Cmdlet 會從 Id 參數所指定的項目開始,清除由 Count 參數所指定的項目數目。例如,如果 Count 為 10 且 Id 為 30,Clear-History 就會清除項目 21 到 30 (含頭尾)。
如果在相同的命令中使用 Count 和 CommandLine 參數,Clear-History 會從 CommandLine 參數所指定的項目開始,清除由 Count 參數所指定的項目數目。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">int</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>Newest</maml:name>
<maml:description>
<maml:para>刪除歷程記錄中最新的項目。根據預設,Clear-History 會刪除歷程記錄中最舊的項目。</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:syntaxItem>
<maml:name>Clear-History</maml:name>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="2">
<maml:name>Count</maml:name>
<maml:description>
<maml:para>由歷程記錄中最舊的項目開始,清除指定的項目數目。
如果在相同的命令中使用 Count 和 Id 參數,此 Cmdlet 會從 Id 參數所指定的項目開始,清除由 Count 參數所指定的項目數目。例如,如果 Count 為 10 且 Id 為 30,Clear-History 就會清除項目 21 到 30 (含頭尾)。
如果在相同的命令中使用 Count 和 CommandLine 參數,Clear-History 會從 CommandLine 參數所指定的項目開始,清除由 Count 參數所指定的項目數目。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">int</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="true" pipelineInput="false" position="named">
<maml:name>CommandLine</maml:name>
<maml:description>
<maml:para>刪除含有指定之文字字串的命令。如果輸入多個字串,Clear-History 會刪除含有其中任何字串的命令。</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>Newest</maml:name>
<maml:description>
<maml:para>刪除歷程記錄中最新的項目。根據預設,Clear-History 會刪除歷程記錄中最舊的項目。</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="false" variableLength="true" globbing="true" pipelineInput="false" position="named">
<maml:name>CommandLine</maml:name>
<maml:description>
<maml:para>刪除含有指定之文字字串的命令。如果輸入多個字串,Clear-History 會刪除含有其中任何字串的命令。</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="2">
<maml:name>Count</maml:name>
<maml:description>
<maml:para>由歷程記錄中最舊的項目開始,清除指定的項目數目。
如果在相同的命令中使用 Count 和 Id 參數,此 Cmdlet 會從 Id 參數所指定的項目開始,清除由 Count 參數所指定的項目數目。例如,如果 Count 為 10 且 Id 為 30,Clear-History 就會清除項目 21 到 30 (含頭尾)。
如果在相同的命令中使用 Count 和 CommandLine 參數,Clear-History 會從 CommandLine 參數所指定的項目開始,清除由 Count 參數所指定的項目數目。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">int</command:parameterValue>
<dev:type>
<maml:name>int</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue></dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="false" position="1">
<maml:name>Id</maml:name>
<maml:description>
<maml:para>刪除具有指定之歷程記錄識別碼的命令。
若要尋找命令的歷程記錄識別碼,請使用 Get-History。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="true">Int32[]</command:parameterValue>
<dev:type>
<maml:name>Int32[]</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>Newest</maml:name>
<maml:description>
<maml:para>刪除歷程記錄中最新的項目。根據預設,Clear-History 會刪除歷程記錄中最舊的項目。</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="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>無</maml:name>
<maml:uri />
<maml:description />
</dev:type>
<maml:description>
<maml:para>
<!-- description -->
您無法經由管道將物件輸出至 Clear-History。
</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>
工作階段歷程記錄是在工作階段期間所輸入命令的清單。您可以檢視歷程記錄、新增及刪除命令,以及從歷程記錄執行命令。如需詳細資訊,請參閱 about_History。
刪除歷程記錄中的命令之後,命令歷程記錄中剩餘項目的歷程記錄識別碼並不會變更。
</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>
clear-history </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>
clear-history -id 23, 25 </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>刪除歷程記錄識別碼為 23 和 25 的命令。</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>
clear-history -command *help*, *command </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>刪除包含 "help" 或以 "command" 結尾的命令。</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>
clear-history -count 10 -newest </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>從歷程記錄刪除 10 個最新命令。</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>
clear-history -id 10 -count 3 </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>從識別碼為 10 的項目開始,刪除三個最舊的命令。</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=135199</maml:uri>
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>about_History</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Get-History</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Add-History</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Invoke-History</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>
Disable-PSRemoting
</command:name>
<maml:description>
<maml:para>防止電腦接收遠端 Windows PowerShell 命令。</maml:para>
</maml:description>
<maml:copyright>
<maml:para></maml:para>
</maml:copyright>
<command:verb>Disable</command:verb>
<command:noun>PSRemoting</command:noun>
<dev:version></dev:version>
</command:details>
<maml:description>
<maml:para>Disable-PSRemoting 函數會將「全部拒絕」項目新增至安全性描述元,藉以停用本機電腦上的所有工作階段設定。這樣會防止本機電腦接收遠端命令。
Disable-PSRemoting 不會停止 WinRM 服務,也不會防止本機電腦的使用者建立連線到遠端電腦的工作階段或傳送命令至其他電腦。
若要重新啟用工作階段設定,請使用 Enable-PSRemoting 或 Enable-PSSessionConfiguration Cmdlet。
若要在 Windows Vista、Windows Server 2008 和更新版的 Windows 上執行這個函數,您必須使用 [以系統管理員身分執行] 選項開啟 Windows PowerShell。</maml:para>
</maml:description>
<!-- Cmdlet syntax section-->
<command:syntax>
<command:syntaxItem>
<maml:name>Disable-PSRemoting</maml:name>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>Force</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>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="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>Force</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>False</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>無</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>無</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>
工作階段設定是指定義工作階段環境的一組設定。工作階段設定位於遠端電腦上,而且由連線到該電腦的本機和遠端工作階段使用。
連線到電腦的每個工作階段都必須使用已在電腦上註冊的其中一個工作階段設定。這包括您使用 New-PSSession 或 Enter-PSSession Cmdlet 建立的固定工作階段,以及在使用利用 WS-Management 遠端技術之 Cmdlet (例如 Invoke-Command) 的 ComputerName 參數時,Windows PowerShell 所建立的暫存工作階段。透過拒絕所有工作階段設定的存取,您就可以有效地防止所有使用者建立連線到電腦的工作階段。
Disable-PSRemoting 的作用相當於 "Disable-PSSessionConfiguration -name *"。
</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>
disable-psremoting </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>
disable-psremoting -force </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>
disable-psremoting -force
C:\PS> new-pssession -computername localhost
[localhost] Connecting to remote server failed with the following error
message : Access is denied. For more information, see the about_Remote_Troub
leshooting Help topic.
+ CategoryInfo : OpenError: (System.Manageme....RemoteRunspace:RemoteRunspace) [], PSRemotingTransportException
+ FullyQualifiedErrorId : PSSessionOpenFailed
C:\PS> new-pssession -computername Server01
Id Name ComputerName State Configuration Availability
-- ---- ------------ ----- ------------- ------------
1 Session1 Server01... Opened Microsoft.PowerShell Available
C:\PS> enable-pssessionConfiguration -name * -force
C:\PS> new-pssession -computername localhost
Id Name ComputerName State Configuration Availability
-- ---- ------------ ----- ------------- ------------
1 Session1 localhost Opened Microsoft.PowerShell Available
</dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個範例會示範使用 Disable-PSRemoting 的作用。
第一個命令會使用 Disable-PSRemoting 來停用本機電腦上所有已註冊的工作階段設定。
第二個命令會使用 New-PSSession 來建立本機電腦的遠端工作階段 (也稱為「回送」)。因為工作階段所需的工作階段設定已停用,所以此命令會失敗。
第三個命令會使用 New-PSSession Cmdlet 來建立從本機電腦連線到 Server01 遠端電腦的工作階段。這個命令 (使用遠端電腦上的工作階段設定) 將會成功。
第四個命令會使用 Enable-PSSessionConfiguration Cmdlet 來重新啟用本機電腦上的所有工作階段設定。此命令會在 Name 參數中使用 * (全部) 值。
第五個命令會嘗試再次使用 New-PSSession 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>
-------------------------- 範例 4 --------------------------
</maml:title>
<maml:introduction>
<maml:para>C:\PS></maml:para>
</maml:introduction>
<dev:code>
disable-psremoting -force
C:\PS> get-psSessionConfiguration | format-table -property name, permission -auto
Name Permission
---- ----------
microsoft.powershell Everyone AccessDenied, BUILTIN\Administrators AccessAllowed
microsoft.powershell32 Everyone AccessDenied, BUILTIN\Administrators AccessAllowed
C:\PS> enable-psremoting -force
WinRM already is set up to receive requests on this machine.
WinRM already is set up for remote management on this machine.
C:\PS>> Get-PSSessionConfiguration | ft name, Permission -auto
Name Permission
---- ----------
microsoft.powershell BUILTIN\Administrators AccessAllowed
microsoft.powershell32 BUILTIN\Administrators AccessAllowed
</dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個範例會示範使用 Disable-PSRemoting 和 Enable-PSRemoting 之工作階段設定的作用。
第一個命令會使用 Disable-PSRemoting 函數來停用所有已註冊的工作階段設定。Force 參數會抑制所有使用者提示。
第二個命令會使用 Get-PSSessionConfiguration Cmdlet 來顯示電腦上已註冊的工作階段設定。此命令會使用管線運算子,將結果傳送至 Format-Table 命令,以便僅在表格中顯示設定的 Name 和 Permission 屬性。
產生的表格顯示拒絕所有人的設定存取權限。
第三個命令會使用 Enable-PSRemoting Cmdlet 來重新啟用電腦上的所有工作階段設定。您也可以使用 "Enable-PsSessionConfiguration -name *" 命令。此命令會使用 Force 參數來抑制所有使用者提示並且重新啟動 WinRM 服務,而不進行提示。
第四個命令會使用 Get-PSSessionConfiguration 和 Format-Table 來顯示工作階段設定的名稱和權限。結果顯示,Administrators 群組的成員現在擁有工作階段設定的存取權。</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=144298</maml:uri>
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Enable-PSRemoting</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Disable-PSSessionConfiguration</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Get-PSSessionConfiguration</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Register-PSSessionConfiguration</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Set-PSSessionConfiguration</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Unregister-PSSessionConfiguration</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>WS-Management Provider</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>
Disable-PSSessionConfiguration
</command:name>
<maml:description>
<maml:para>拒絕存取本機電腦的工作階段設定。</maml:para>
</maml:description>
<maml:copyright>
<maml:para></maml:para>
</maml:copyright>
<command:verb>Disable</command:verb>
<command:noun>PSSessionConfiguration</command:noun>
<dev:version></dev:version>
</command:details>
<maml:description>
<maml:para>Disable-PSSessionConfiguration Cmdlet 會防止所有電腦使用者在工作階段中使用工作階段設定。這是進階的 Cmdlet,適合系統管理員用來管理使用者的自訂工作階段設定。
Disable-PSSessionConfiguration Cmdlet 會將「全部拒絕」設定新增至一個或多個已註冊工作階段設定的安全性描述元。因此,雖然您可以取消註冊、檢視和變更設定,不過無法在工作階段中使用它們。
如果沒有使用參數,Disable-PSSessionConfiguration 就會停用 Microsoft.PowerShell 設定 (用於工作階段的預設設定)。除非使用者指定了不同的設定,否則系統會有效地防止本機和遠端使用者建立連線到電腦的任何工作階段。
若要停用電腦上的所有工作階段設定,請使用 Disable-PSRemoting。</maml:para>
</maml:description>
<!-- Cmdlet syntax section-->
<command:syntax>
<command:syntaxItem>
<maml:name>Disable-PSSessionConfiguration</maml:name>
<command:parameter required="false" variableLength="true" globbing="true" pipelineInput="true (ByValue, ByPropertyName)" position="1">
<maml:name>Name</maml:name>
<maml:description>
<maml:para>指定要停用之工作階段設定的名稱。請輸入一個或多個設定名稱。允許使用萬用字元。您也可以經由管道將包含設定名稱的字串或工作階段設定物件輸出至 Disable-PSSessionConfiguration。
如果您省略這個參數,Disable-PSSessionConfiguration 就會停用 Microsoft.PowerShell 工作階段設定。</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>Force</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>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="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>Force</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>False</dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="true" pipelineInput="true (ByValue, ByPropertyName)" position="1">
<maml:name>Name</maml:name>
<maml:description>
<maml:para>指定要停用之工作階段設定的名稱。請輸入一個或多個設定名稱。允許使用萬用字元。您也可以經由管道將包含設定名稱的字串或工作階段設定物件輸出至 Disable-PSSessionConfiguration。
如果您省略這個參數,Disable-PSSessionConfiguration 就會停用 Microsoft.PowerShell 工作階段設定。</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>Microsoft.PowerShell</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.Commands.PSSessionConfigurationCommands#PSSessionConfiguration 或 System.String</maml:name>
<maml:uri />
<maml:description />
</dev:type>
<maml:description>
<maml:para>
<!-- description -->
您可經由管道將工作階段設定物件或包含工作階段設定名稱的字串輸出至 Disable-PSSessionConfiguration。
</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>
若要在 Windows Vista、Windows Server 2008 和更新版的 Windows 上執行這個 Cmdlet,您必須使用 [以系統管理員身分執行] 選項啟動 Windows PowerShell。
</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>
Disable-PSSessionConfiguration </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個命令會停用 Microsoft.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>
-------------------------- 範例 2 --------------------------
</maml:title>
<maml:introduction>
<maml:para>C:\PS></maml:para>
</maml:introduction>
<dev:code>
disable-pssessionConfiguration -name * </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>
disable-pssessionConfiguration -name Microsoft* -force </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個命令會停用名稱以 "Microsoft" 為開頭的所有工作階段設定。此命令會使用 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>
Get-PSSessionConfiguration -name MaintenanceShell, AdminShell | Disable-PSSessionConfiguration </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個命令會停用 MaintenanceShell 和 AdminShell 工作階段設定。
此命令會使用管線運算子 (|),將 Get-PSSessionConfiguration 命令的結果傳送至 Disable-PSSessionConfiguration。</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>
Get-PSSessionConfiguration | format-table -property Name, Permission -auto
Name Permission
---- ----------
MaintenanceShell BUILTIN\Administrators AccessAllowed
microsoft.powershell BUILTIN\Administrators AccessAllowed
microsoft.powershell32 BUILTIN\Administrators AccessAllowed
C:\PS> Disable-PSSessionConfiguration -name MaintenanceShell -force
C:\PS> Get-PSSessionConfiguration | format-table -property Name, Permission -auto
Name Permission
---- ----------
MaintenanceShell Everyone AccessDenied, BUILTIN\Administrators AccessAllowed
microsoft.powershell BUILTIN\Administrators AccessAllowed
microsoft.powershell32 BUILTIN\Administrators AccessAllowed
C:\PS> Set-PSSessionConfiguration -name MaintenanceShell -MaximumReceivedDataSizePerCommandMB 60
ParamName ParamValue
--------- ----------
psmaximumreceived... 60
"Restart WinRM service"
WinRM service need to be restarted to make the changes effective. Do you want to run the command "restart-service winrm"?
[Y] Yes [N] No [S] Suspend [?] Help (default is "Y"): y
C:\PS> new-pssession -computername localhost -configurationName MaintenanceShell
[localhost] Connecting to remote server failed with the following error message : Access is denied. For more information, see the about_Remote_Troubl
eshooting Help topic.
+ CategoryInfo : OpenError: (System.Manageme....RemoteRunspace:RemoteRunspace) [], PSRemotingTransportException
+ FullyQualifiedErrorId : PSSessionOpenFailed </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個範例會示範停用工作階段設定的作用。
第一個命令會使用 Get-SessionConfiguration 和 Format-Table Cmdlet,僅顯示工作階段設定物件的 Name 和 Permission 屬性。這種表格格式可方便您查看物件的值。結果顯示,Administrators 群組的成員允許使用工作階段設定。
第二個命令會使用 Disable-PSSessionConfiguration Cmdlet 來停用 MaintenanceShell 工作階段設定。此命令會使用 Force 參數來抑制所有使用者提示。
第三個命令與第一個命令重複。結果顯示,您仍然可以取得代表 MaintenanceShell 工作階段設定的物件,即使拒絕所有人的存取權也一樣。"AccessDenied" 項目的優先順序高於安全性描述元中的所有其他項目。
第四個命令會使用 Set-PSSessionConfiguration Cmdlet,將 MaintenanceShell 工作階段設定的 MaximumDataSizePerCommandMB 設定增加至 60。結果顯示,此命令會成功,即使拒絕所有人的設定存取權也一樣。
第五個命令會嘗試在工作階段中使用 MaintenanceShell 工作階段設定。它會使用 New-PSSession Cmdlet 來建立新的工作階段,並且使用 ConfigurationName 參數來指定 MaintenanceShell 設定。結果顯示,New-PSSession 命令會失敗,因為拒絕使用者的設定存取權。
</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=144299</maml:uri>
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>about_Session_Configurations</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Enable-PSSessionConfiguration</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Get-PSSessionConfiguration</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Register-PSSessionConfiguration</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Set-PSSessionConfiguration</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Unregister-PSSessionConfiguration</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>WS-Management Provider</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>
Enable-PSRemoting
</command:name>
<maml:description>
<maml:para>設定電腦以接收遠端命令。</maml:para>
</maml:description>
<maml:copyright>
<maml:para></maml:para>
</maml:copyright>
<command:verb>Enable</command:verb>
<command:noun>PSRemoting</command:noun>
<dev:version></dev:version>
</command:details>
<maml:description>
<maml:para>Enable-PSRemoting Cmdlet 會將電腦設定成接收使用 WS-Management 技術所傳送的 Windows PowerShell 遠端命令。
您只要在即將接收命令的每部電腦上執行一次這個命令即可。您不需要在僅傳送命令的電腦上執行此命令。因為此設定會啟動接聽程式,所以請務必只在需要時執行此命令。
Enable-PSRemoting Cmdlet 會執行下列作業:
-- 執行 Set-WSManQuickConfig Cmdlet,以便執行下列工作:
----- 啟動 WinRM 服務。
----- 將 WinRM 服務的啟動類型設定為自動。
----- 建立接聽程式以接受任何 IP 位址的要求。
----- 針對 WS-Management 通訊啟用防火牆例外。
-- 啟用所有已註冊的 Windows PowerShell 工作階段設定,以便從遠端電腦接收指示。
----- 註冊 "Microsoft.PowerShell" 工作階段設定 (如果尚未註冊的話)。
----- 在 64 位元電腦上註冊 "Microsoft.PowerShell32" 工作階段設定 (如果尚未註冊的話)。
----- 從所有已註冊工作階段設定的安全性描述元中移除「拒絕所有人」設定。
----- 重新啟動 WinRM 服務,讓上述變更生效。
若要在 Windows Vista、Windows Server 2008 和更新版的 Windows 上執行這個 Cmdlet,您必須使用 [以系統管理員身分執行] 選項啟動 Windows PowerShell。</maml:para>
</maml:description>
<!-- Cmdlet syntax section-->
<command:syntax>
<command:syntaxItem>
<maml:name>Enable-PSRemoting</maml:name>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>Force</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>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="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>Force</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>False</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>無</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.String</maml:name>
<maml:uri />
<maml:description />
</dev:type>
<maml:description>
<maml:para>
<!-- description -->
Enable-PSRemoting 會傳回描述其結果的字串。
</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>
enable-psremoting </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>
enable-psremoting -force </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個命令會將電腦設定成接收遠端命令。它會使用 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=144300</maml:uri>
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>about_Remote</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>about_Session_Configurations</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Disable-PSRemoting</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Get-PSSessionConfiguration</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Enable-PSSessionConfiguration</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Disable-PSSessionConfiguration</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Register-PSSessionConfiguration</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Set-PSSessionConfiguration</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>WS-Management Provider</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>
Enable-PSSessionConfiguration
</command:name>
<maml:description>
<maml:para>啟用本機電腦的工作階段設定。</maml:para>
</maml:description>
<maml:copyright>
<maml:para></maml:para>
</maml:copyright>
<command:verb>Enable</command:verb>
<command:noun>PSSessionConfiguration</command:noun>
<dev:version></dev:version>
</command:details>
<maml:description>
<maml:para>Enable-PSSessionConfiguration Cmdlet 會重新啟用已經使用 Disable-PSSessionConfiguration Cmdlet 停用的已註冊工作階段設定。這是進階的 Cmdlet,適合系統管理員用來管理使用者的自訂工作階段設定。
如果沒有使用參數,Enable-PSSessionConfiguration 就會重新啟用 Microsoft.PowerShell 設定 (用於工作階段的預設設定)。
這個 Cmdlet 會針對每個啟用的設定執行下列作業:
-- 從設定的安全性描述元中移除「全部拒絕」設定,或以您所指定的安全性描述元取代現有的安全性描述元。
-- 開啟接受任何 IP 位址之要求的接聽程式。
-- 重新啟動 WinRM 服務。
Enable-PSSessionConfiguration Cmdlet 會呼叫 Set-WSManQuickConfig Cmdlet。不過,它不應該用來啟用電腦的遠端功能。請改用 Enable-PSRemoting 這個更完整的 Cmdlet。</maml:para>
</maml:description>
<!-- Cmdlet syntax section-->
<command:syntax>
<command:syntaxItem>
<maml:name>Enable-PSSessionConfiguration</maml:name>
<command:parameter required="false" variableLength="true" globbing="true" pipelineInput="true (ByValue, ByPropertyName)" position="1">
<maml:name>Name</maml:name>
<maml:description>
<maml:para>指定要啟用之工作階段設定的名稱。請輸入一個或多個設定名稱。允許使用萬用字元。
您也可以經由管道將包含設定名稱的字串或工作階段設定物件輸出至 Enable-PSSessionConfiguration。
如果您省略這個參數,Enable-PSSessionConfiguration 就會啟用 Microsoft.PowerShell 工作階段設定。</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>Force</maml:name>
<maml:description>
<maml:para>抑制所有使用者提示,並重新啟動 WinRM 服務,而不進行提示。重新啟動服務可讓設定變更生效。
若要防止進行重新啟動並抑制重新啟動的提示,請使用 NoServiceRestart 參數。</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>SecurityDescriptorSDDL</maml:name>
<maml:description>
<maml:para>以指定的安全性描述元取代工作階段設定的安全性描述元。
如果您省略這個參數,Enable-PSSessionConfiguration 只會從安全性描述元中刪除「全部拒絕」項目。</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="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>Force</maml:name>
<maml:description>
<maml:para>抑制所有使用者提示,並重新啟動 WinRM 服務,而不進行提示。重新啟動服務可讓設定變更生效。
若要防止進行重新啟動並抑制重新啟動的提示,請使用 NoServiceRestart 參數。</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="true" pipelineInput="true (ByValue, ByPropertyName)" position="1">
<maml:name>Name</maml:name>
<maml:description>
<maml:para>指定要啟用之工作階段設定的名稱。請輸入一個或多個設定名稱。允許使用萬用字元。
您也可以經由管道將包含設定名稱的字串或工作階段設定物件輸出至 Enable-PSSessionConfiguration。
如果您省略這個參數,Enable-PSSessionConfiguration 就會啟用 Microsoft.PowerShell 工作階段設定。</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>SecurityDescriptorSDDL</maml:name>
<maml:description>
<maml:para>以指定的安全性描述元取代工作階段設定的安全性描述元。
如果您省略這個參數,Enable-PSSessionConfiguration 只會從安全性描述元中刪除「全部拒絕」項目。</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>Microsoft.PowerShell.Commands.PSSessionConfigurationCommands#PSSessionConfiguration 或 System.String</maml:name>
<maml:uri />
<maml:description />
</dev:type>
<maml:description>
<maml:para>
<!-- description -->
您可經由管道將工作階段設定物件或包含工作階段設定名稱的字串輸出至 Enable-PSSessionConfiguration。
</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>
若要在 Windows Vista、Windows Server 2008 和更新版的 Windows 上執行這個 Cmdlet,您必須使用 [以系統管理員身分執行] 選項啟動 Windows PowerShell。
</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>
Enable-PSSessionConfiguration </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個命令會重新啟用電腦上的 Microsoft.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>
-------------------------- 範例 2 --------------------------
</maml:title>
<maml:introduction>
<maml:para>C:\PS></maml:para>
</maml:introduction>
<dev:code>
Enable-PSSessionConfiguration -name MaintenanceShell, AdminShell </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個命令會重新啟用電腦上的 MaintenanceShell 和 AdminShell 工作階段設定。</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>
Enable-PSSessionConfiguration -name *
C:\PS> Get-PSSessionConfiguration | Enable-PSSessionConfiguration </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這些命令會重新啟用電腦上的所有工作階段設定。這些命令的作用相同,所以您可以使用任何一個命令。
如果您啟用已經啟用的工作階段設定,Enable-PSSessionConfiguration 不會產生錯誤。</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>
Enable-PSSessionConfiguration -name MaintenanceShell -securityDescriptorSDDL "O:NSG:BAD:P(A;;GXGWGR;;;BA)(A;;GAGR;;;S-1-5-21-123456789-188441444-3100496)S:P" </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個命令會重新啟用 MaintenanceShell 工作階段設定並針對此設定指定新的安全性描述元。</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=144301</maml:uri>
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>about_Session_Configurations</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Disable-PSSessionConfiguration</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Get-PSSessionConfiguration</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Register-PSSessionConfiguration</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Set-PSSessionConfiguration</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Unregister-PSSessionConfiguration</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>WS-Management Provider</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>
Enter-PSSession
</command:name>
<maml:description>
<maml:para>啟動與遠端電腦之間的互動式工作階段。</maml:para>
</maml:description>
<maml:copyright>
<maml:para></maml:para>
</maml:copyright>
<command:verb>Enter</command:verb>
<command:noun>PSSession</command:noun>
<dev:version></dev:version>
</command:details>
<maml:description>
<maml:para>Enter-PSSession Cmdlet 會啟動與單一遠端電腦之間的互動式工作階段。在工作階段期間,您所輸入的命令會在遠端電腦上執行,就好像是在遠端電腦上直接輸入命令一樣。您一次只能有一個互動式工作階段。
通常您會使用 ComputerName 參數指定遠端電腦名稱。但是,您也可以將透過 New-PSSession 所建立的工作階段用於互動式工作階段。
若要結束互動式工作階段並中斷與遠端電腦的連線,請使用 Exit-PSSession Cmdlet 或輸入 "exit"。</maml:para>
</maml:description>
<!-- Cmdlet syntax section-->
<command:syntax>
<command:syntaxItem>
<maml:name>Enter-PSSession</maml:name>
<command:parameter required="true" variableLength="false" globbing="false" pipelineInput="true (ByValue, ByPropertyName)" position="1">
<maml:name>ComputerName</maml:name>
<maml:description>
<maml:para>啟動與指定之遠端電腦間的互動式工作階段。請輸入一個電腦名稱即可。預設為本機電腦。
請輸入一部或多部遠端電腦的 NetBIOS 名稱、IP 位址或完整網域名稱。您也可以經由管道將電腦名稱輸出至 Enter-PSSession。
若要在 ComputerName 參數的值中使用 IP 位址,命令必須包含 Credential 參數。而且,該電腦必須設定成 HTTPS 傳輸,或者遠端電腦的 IP 位址必須包含在本機電腦的 WinRM TrustedHosts 清單中。如需將電腦名稱新增到 TrustedHosts 清單的指示,請參閱 about_Remote_Troubleshooting 中的<如何將電腦新增到信任的主機清單>。
注意:在 Windows Vista 和更新版的 Windows 中,若要在 ComputerName 參數值中包含本機電腦,您必須以 [以系統管理員身分執行] 選項啟動 Windows PowerShell。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">string</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="true (ByPropertyName)" position="named">
<maml:name>ApplicationName</maml:name>
<maml:description>
<maml:para>指定連線 URI 的應用程式名稱區段。當您沒有在命令中使用 ConnectionURI 參數時,可以使用此參數指定應用程式名稱。
預設值為本機電腦上的 $PSSessionApplicationName 喜好設定變數的值。如果沒有定義此喜好設定變數,則預設值為 WSMAN。這個值適合大部分使用情況。如需詳細資訊,請參閱 about_Preference_Variables。
WinRM 服務會使用應用程式名稱來選取要服務連線要求的接聽程式。這個參數的值必須符合遠端電腦上接聽程式的 URLPrefix 屬性值。</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>Authentication</maml:name>
<maml:description>
<maml:para>指定用來驗證使用者認證的機制。有效值為 "Default"、"Basic"、"Credssp"、"Digest"、"Kerberos"、"Negotiate" 和 "NegotiateWithImplicitCredential"。預設值為 "Default"。
CredSSP 驗證僅適用於 Windows Vista、Windows Server 2008 和更新版的 Windows。
如需這個參數值的詳細資訊,請參閱 MSDN (Microsoft Developer Network) Library 中的 System.Management.Automation.Runspaces.AuthenticationMechanism 列舉說明,網址為:http://go.microsoft.com/fwlink/?LinkId=144382 (英文)。
警告:認證安全性服務提供者 (CredSSP) 驗證 (其中使用者的認證會傳送到遠端電腦) 是專為需要對一個以上的資源進行驗證的命令所設計,例如存取遠端網路共用。此機制會提高遠端操作的安全性風險。如果遠端電腦已經遭受危害,則傳遞給遠端電腦的認證可能會被用來控制網路工作階段。</maml:para>
</maml:description>
<command:parameterValueGroup>
<command:parameterValue required="false" variableLength="false">Default</command:parameterValue>
<command:parameterValue required="false" variableLength="false">Basic</command:parameterValue>
<command:parameterValue required="false" variableLength="false">Negotiate</command:parameterValue>
<command:parameterValue required="false" variableLength="false">NegotiateWithImplicitCredential</command:parameterValue>
<command:parameterValue required="false" variableLength="false">Credssp</command:parameterValue>
<command:parameterValue required="false" variableLength="false">Digest</command:parameterValue>
<command:parameterValue required="false" variableLength="false">Kerberos</command:parameterValue>
</command:parameterValueGroup>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>CertificateThumbprint</maml:name>
<maml:description>
<maml:para>對於具有執行此動作之權限的使用者帳戶,指定其數位公開金鑰憑證 (X509)。請輸入憑證的憑證指紋。
憑證係在進行用戶端憑證式驗證時使用。這些憑證只能對應到本機使用者帳戶,並不適用於網域帳戶。
若要取得憑證指紋,請在 Windows PowerShell 的 Cert: 磁碟機中使用 Get-Item 或 Get-ChildItem 命令。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">string</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="true (ByPropertyName)" position="named">
<maml:name>ConfigurationName</maml:name>
<maml:description>
<maml:para>指定用於互動式工作階段的工作階段設定。
請輸入工作階段設定的設定名稱或完整資源 URI。如果只指定設定名稱,則會在其前面加上下列結構描述 URI:http://schemas.microsoft.com/powershell。
工作階段的工作階段設定是位於遠端電腦。如果遠端電腦上沒有指定的工作階段設定,則命令會失敗。
預設值為本機電腦上的 $PSSessionConfigurationName 喜好設定變數的值。如果沒有設定此喜好設定變數,則預設值為 Microsoft.PowerShell。如需詳細資訊,請參閱 about_Preference_Variables。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">string</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="true (ByPropertyName)" position="named">
<maml:name>Credential</maml:name>
<maml:description>
<maml:para>指定具有執行此動作之權限的使用者帳戶。預設為目前使用者。
請輸入使用者名稱,例如 "User01"、"Domain01\User01" 或 "User@Domain.com",或是輸入 PSCredential 物件,例如 Get-Credential Cmdlet 傳回的物件。
當您輸入使用者名稱時,會提示您輸入密碼。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">PSCredential</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>Port</maml:name>
<maml:description>
<maml:para>指定遠端電腦上要供此命令使用的網路連接埠。預設為連接埠 80 (HTTP 連接埠)。
使用其他連接埠之前,必須先於遠端電腦上設定 WinRM 接聽程式,以接聽該連接埠。請使用下列命令設定接聽程式:
1. winrm delete winrm/config/listener?Address=*+Transport=HTTP
2. winrm create winrm/config/listener?Address=*+Transport=HTTP @{Port="<連接埠號碼>"}
除非必要,否則請勿使用 Port 參數。命令中的連接埠設定適用於執行命令的所有電腦或工作階段。其他連接埠設定可能會導致無法在所有電腦上執行命令。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">int</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>SessionOption</maml:name>
<maml:description>
<maml:para>設定工作階段的進階選項。請輸入使用 New-PSSessionOption Cmdlet 所建立的 SessionOption 物件。
如果有設定 $PSSessionOption 喜好設定變數的值,它會決定選項的預設值。否則,工作階段會使用系統預設值。
如需工作階段選項 (包括預設值) 的描述,請參閱 New-PSSessionOption。如需 $PSSessionOption 喜好設定變數的詳細資訊,請參閱 about_Preference_Variables。
</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">PSSessionOption</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>UseSSL</maml:name>
<maml:description>
<maml:para>使用安全通訊端層 (SSL) 通訊協定建立與遠端電腦的連線。預設不會使用 SSL,
因為 WS-Management 會將所有透過網路傳輸的 Windows PowerShell 內容加密。使用 UseSSL 時,便會透過 HTTPS 連線 (而非 HTTP 連線) 傳送資料,提供多一層防護。
如果使用此參數,但是供命令使用的連接埠無法使用 SSL,則命令會失敗。</maml:para>
</maml:description>
</command:parameter>
</command:syntaxItem>
<command:syntaxItem>
<maml:name>Enter-PSSession</maml:name>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="true (ByPropertyName)" position="1">
<maml:name>Id</maml:name>
<maml:description>
<maml:para>指定現有工作階段的識別碼。Enter-PSSession 會將指定的工作階段用於互動式工作階段。
若要尋找工作階段的識別碼,請使用 Get-PSSession Cmdlet。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">int</command:parameterValue>
</command:parameter>
</command:syntaxItem>
<command:syntaxItem>
<maml:name>Enter-PSSession</maml:name>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="true (ByPropertyName)" position="named">
<maml:name>InstanceId</maml:name>
<maml:description>
<maml:para>指定現有工作階段的執行個體識別碼。Enter-PSSession 會將指定的工作階段用於互動式工作階段。
執行個體識別碼是一種 GUID。若要尋找工作階段的執行個體識別碼,請使用 Get-PSSession Cmdlet。您也可以使用 Session、Name 或 ID 參數指定現有的工作階段。或者,使用 ComputerName 參數啟動暫存工作階段。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">Guid</command:parameterValue>
</command:parameter>
</command:syntaxItem>
<command:syntaxItem>
<maml:name>Enter-PSSession</maml:name>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="true (ByPropertyName)" position="named">
<maml:name>Name</maml:name>
<maml:description>
<maml:para>指定現有工作階段的好記名稱。Enter-PSSession 會將指定的工作階段用於互動式工作階段。
如果指定的名稱符合多個工作階段,命令會失敗。您也可以使用 Session、InstanceID 或 ID 參數指定現有的工作階段。或者,使用 ComputerName 參數啟動暫存工作階段。
若要建立好記的工作階段名稱,請使用 New-PSSession Cmdlet 的 Name 參數。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">string</command:parameterValue>
</command:parameter>
</command:syntaxItem>
<command:syntaxItem>
<maml:name>Enter-PSSession</maml:name>
<command:parameter required="false" variableLength="false" globbing="true" pipelineInput="true (ByValue, ByPropertyName)" position="1">
<maml:name>Session</maml:name>
<maml:description>
<maml:para>指定要用於互動式工作階段的 Windows PowerShell 的工作階段 (PSSession)。此參數會接受工作階段物件。您也可以使用 Name、InstanceID 或 ID 參數指定 PSSession。
請輸入包含工作階段物件的變數,或者輸入建立或取得工作階段物件的命令,例如 New-PSSession 或 Get-PSSession 命令。您也可以經由管道將工作階段物件輸出至 Enter-PSSession。指定此參數時,只能提交一個 PSSession。如果所輸入的變數包含多個 PSSession,命令會失敗。
使用 Exit-PSSession 或 EXIT 關鍵字即可結束互動式工作階段,但是所建立的 PSSession 仍然開啟且可供使用。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">PSSession</command:parameterValue>
</command:parameter>
</command:syntaxItem>
<command:syntaxItem>
<maml:name>Enter-PSSession</maml:name>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="true (ByPropertyName)" position="2">
<maml:name>ConnectionURI</maml:name>
<maml:description>
<maml:para>指定定義互動式工作階段之連線端點的統一資源識別項 (URI)。此 URI 必須是完整的 URI。
這個字串的格式如下所示:
<傳輸方式>://<電腦名稱>:<連接埠>/<應用程式名稱>
預設值如下所示:
http://localhost:80/WSMAN
URI 中傳輸方式區段的有效值為 HTTP 和 HTTPS。如果未指定 ConnectionURI,就必須使用 UseSSL、ComputerName、Port 和 ApplicationName 參數指定 URI 值。
如果目的電腦將連線重新導向到不同的 URI,那麼除非您在命令中使用 AllowRedirection 參數,否則 Windows PowerShell 不會重新導向連線。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">Uri</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>AllowRedirection</maml:name>
<maml:description>
<maml:para>允許將這個連線重新導向至替代統一資源識別項 (URI)。
在使用 ConnectionURI 參數時,遠端目的地可能會傳回指示,以重新導向至不同的 URI。根據預設,Windows PowerShell 不會重新導向連線,但是您可以使用此參數允許它重新導向連線。
允許這個連線重新導向到其他 URI。
在使用 ConnectionURI 參數時,遠端目的地可能會傳回指示,以重新導向至不同的 URI。根據預設,Windows PowerShell 不會重新導向連線,但是您可以使用 AllowRedirection 參數允許它重新導向連線。
您也可以設定 $PSSessionOption 喜好設定變數的 MaximumConnectionRedirectionCount 屬性或 SessionOption 參數的 MaximumConnectionRedirectionCount 屬性值,藉此限制連線的重新導向次數。預設值為 5。如需詳細資訊,請參閱 SessionOption 參數的描述以及 New-PSSessionOption。
</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>Authentication</maml:name>
<maml:description>
<maml:para>指定用來驗證使用者認證的機制。有效值為 "Default"、"Basic"、"Credssp"、"Digest"、"Kerberos"、"Negotiate" 和 "NegotiateWithImplicitCredential"。預設值為 "Default"。
CredSSP 驗證僅適用於 Windows Vista、Windows Server 2008 和更新版的 Windows。
如需這個參數值的詳細資訊,請參閱 MSDN (Microsoft Developer Network) Library 中的 System.Management.Automation.Runspaces.AuthenticationMechanism 列舉說明,網址為:http://go.microsoft.com/fwlink/?LinkId=144382 (英文)。
警告:認證安全性服務提供者 (CredSSP) 驗證 (其中使用者的認證會傳送到遠端電腦) 是專為需要對一個以上的資源進行驗證的命令所設計,例如存取遠端網路共用。此機制會提高遠端操作的安全性風險。如果遠端電腦已經遭受危害,則傳遞給遠端電腦的認證可能會被用來控制網路工作階段。</maml:para>
</maml:description>
<command:parameterValueGroup>
<command:parameterValue required="false" variableLength="false">Default</command:parameterValue>
<command:parameterValue required="false" variableLength="false">Basic</command:parameterValue>
<command:parameterValue required="false" variableLength="false">Negotiate</command:parameterValue>
<command:parameterValue required="false" variableLength="false">NegotiateWithImplicitCredential</command:parameterValue>
<command:parameterValue required="false" variableLength="false">Credssp</command:parameterValue>
<command:parameterValue required="false" variableLength="false">Digest</command:parameterValue>
<command:parameterValue required="false" variableLength="false">Kerberos</command:parameterValue>
</command:parameterValueGroup>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>CertificateThumbprint</maml:name>
<maml:description>
<maml:para>對於具有執行此動作之權限的使用者帳戶,指定其數位公開金鑰憑證 (X509)。請輸入憑證的憑證指紋。
憑證係在進行用戶端憑證式驗證時使用。這些憑證只能對應到本機使用者帳戶,並不適用於網域帳戶。
若要取得憑證指紋,請在 Windows PowerShell 的 Cert: 磁碟機中使用 Get-Item 或 Get-ChildItem 命令。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">string</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="true (ByPropertyName)" position="named">
<maml:name>ConfigurationName</maml:name>
<maml:description>
<maml:para>指定用於互動式工作階段的工作階段設定。
請輸入工作階段設定的設定名稱或完整資源 URI。如果只指定設定名稱,則會在其前面加上下列結構描述 URI:http://schemas.microsoft.com/powershell。
工作階段的工作階段設定是位於遠端電腦。如果遠端電腦上沒有指定的工作階段設定,則命令會失敗。
預設值為本機電腦上的 $PSSessionConfigurationName 喜好設定變數的值。如果沒有設定此喜好設定變數,則預設值為 Microsoft.PowerShell。如需詳細資訊,請參閱 about_Preference_Variables。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">string</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="true (ByPropertyName)" position="named">
<maml:name>Credential</maml:name>
<maml:description>
<maml:para>指定具有執行此動作之權限的使用者帳戶。預設為目前使用者。
請輸入使用者名稱,例如 "User01"、"Domain01\User01" 或 "User@Domain.com",或是輸入 PSCredential 物件,例如 Get-Credential Cmdlet 傳回的物件。
當您輸入使用者名稱時,會提示您輸入密碼。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">PSCredential</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>SessionOption</maml:name>
<maml:description>
<maml:para>設定工作階段的進階選項。請輸入使用 New-PSSessionOption Cmdlet 所建立的 SessionOption 物件。
如果有設定 $PSSessionOption 喜好設定變數的值,它會決定選項的預設值。否則,工作階段會使用系統預設值。
如需工作階段選項 (包括預設值) 的描述,請參閱 New-PSSessionOption。如需 $PSSessionOption 喜好設定變數的詳細資訊,請參閱 about_Preference_Variables。
</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">PSSessionOption</command:parameterValue>
</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>AllowRedirection</maml:name>
<maml:description>
<maml:para>允許將這個連線重新導向至替代統一資源識別項 (URI)。
在使用 ConnectionURI 參數時,遠端目的地可能會傳回指示,以重新導向至不同的 URI。根據預設,Windows PowerShell 不會重新導向連線,但是您可以使用此參數允許它重新導向連線。
允許這個連線重新導向到其他 URI。
在使用 ConnectionURI 參數時,遠端目的地可能會傳回指示,以重新導向至不同的 URI。根據預設,Windows PowerShell 不會重新導向連線,但是您可以使用 AllowRedirection 參數允許它重新導向連線。
您也可以設定 $PSSessionOption 喜好設定變數的 MaximumConnectionRedirectionCount 屬性或 SessionOption 參數的 MaximumConnectionRedirectionCount 屬性值,藉此限制連線的重新導向次數。預設值為 5。如需詳細資訊,請參閱 SessionOption 參數的描述以及 New-PSSessionOption。
</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="named">
<maml:name>ApplicationName</maml:name>
<maml:description>
<maml:para>指定連線 URI 的應用程式名稱區段。當您沒有在命令中使用 ConnectionURI 參數時,可以使用此參數指定應用程式名稱。
預設值為本機電腦上的 $PSSessionApplicationName 喜好設定變數的值。如果沒有定義此喜好設定變數,則預設值為 WSMAN。這個值適合大部分使用情況。如需詳細資訊,請參閱 about_Preference_Variables。
WinRM 服務會使用應用程式名稱來選取要服務連線要求的接聽程式。這個參數的值必須符合遠端電腦上接聽程式的 URLPrefix 屬性值。</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>WSMAN</dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>Authentication</maml:name>
<maml:description>
<maml:para>指定用來驗證使用者認證的機制。有效值為 "Default"、"Basic"、"Credssp"、"Digest"、"Kerberos"、"Negotiate" 和 "NegotiateWithImplicitCredential"。預設值為 "Default"。
CredSSP 驗證僅適用於 Windows Vista、Windows Server 2008 和更新版的 Windows。
如需這個參數值的詳細資訊,請參閱 MSDN (Microsoft Developer Network) Library 中的 System.Management.Automation.Runspaces.AuthenticationMechanism 列舉說明,網址為:http://go.microsoft.com/fwlink/?LinkId=144382 (英文)。
警告:認證安全性服務提供者 (CredSSP) 驗證 (其中使用者的認證會傳送到遠端電腦) 是專為需要對一個以上的資源進行驗證的命令所設計,例如存取遠端網路共用。此機制會提高遠端操作的安全性風險。如果遠端電腦已經遭受危害,則傳遞給遠端電腦的認證可能會被用來控制網路工作階段。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">AuthenticationMechanism</command:parameterValue>
<dev:type>
<maml:name>AuthenticationMechanism</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>CertificateThumbprint</maml:name>
<maml:description>
<maml:para>對於具有執行此動作之權限的使用者帳戶,指定其數位公開金鑰憑證 (X509)。請輸入憑證的憑證指紋。
憑證係在進行用戶端憑證式驗證時使用。這些憑證只能對應到本機使用者帳戶,並不適用於網域帳戶。
若要取得憑證指紋,請在 Windows PowerShell 的 Cert: 磁碟機中使用 Get-Item 或 Get-ChildItem 命令。</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="true" variableLength="false" globbing="false" pipelineInput="true (ByValue, ByPropertyName)" position="1">
<maml:name>ComputerName</maml:name>
<maml:description>
<maml:para>啟動與指定之遠端電腦間的互動式工作階段。請輸入一個電腦名稱即可。預設為本機電腦。
請輸入一部或多部遠端電腦的 NetBIOS 名稱、IP 位址或完整網域名稱。您也可以經由管道將電腦名稱輸出至 Enter-PSSession。
若要在 ComputerName 參數的值中使用 IP 位址,命令必須包含 Credential 參數。而且,該電腦必須設定成 HTTPS 傳輸,或者遠端電腦的 IP 位址必須包含在本機電腦的 WinRM TrustedHosts 清單中。如需將電腦名稱新增到 TrustedHosts 清單的指示,請參閱 about_Remote_Troubleshooting 中的<如何將電腦新增到信任的主機清單>。
注意:在 Windows Vista 和更新版的 Windows 中,若要在 ComputerName 參數值中包含本機電腦,您必須以 [以系統管理員身分執行] 選項啟動 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="false" globbing="false" pipelineInput="true (ByPropertyName)" position="named">
<maml:name>ConfigurationName</maml:name>
<maml:description>
<maml:para>指定用於互動式工作階段的工作階段設定。
請輸入工作階段設定的設定名稱或完整資源 URI。如果只指定設定名稱,則會在其前面加上下列結構描述 URI:http://schemas.microsoft.com/powershell。
工作階段的工作階段設定是位於遠端電腦。如果遠端電腦上沒有指定的工作階段設定,則命令會失敗。
預設值為本機電腦上的 $PSSessionConfigurationName 喜好設定變數的值。如果沒有設定此喜好設定變數,則預設值為 Microsoft.PowerShell。如需詳細資訊,請參閱 about_Preference_Variables。</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="true (ByPropertyName)" position="2">
<maml:name>ConnectionURI</maml:name>
<maml:description>
<maml:para>指定定義互動式工作階段之連線端點的統一資源識別項 (URI)。此 URI 必須是完整的 URI。
這個字串的格式如下所示:
<傳輸方式>://<電腦名稱>:<連接埠>/<應用程式名稱>
預設值如下所示:
http://localhost:80/WSMAN
URI 中傳輸方式區段的有效值為 HTTP 和 HTTPS。如果未指定 ConnectionURI,就必須使用 UseSSL、ComputerName、Port 和 ApplicationName 參數指定 URI 值。
如果目的電腦將連線重新導向到不同的 URI,那麼除非您在命令中使用 AllowRedirection 參數,否則 Windows PowerShell 不會重新導向連線。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">Uri</command:parameterValue>
<dev:type>
<maml:name>Uri</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue></dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="true (ByPropertyName)" position="named">
<maml:name>Credential</maml:name>
<maml:description>
<maml:para>指定具有執行此動作之權限的使用者帳戶。預設為目前使用者。
請輸入使用者名稱,例如 "User01"、"Domain01\User01" 或 "User@Domain.com",或是輸入 PSCredential 物件,例如 Get-Credential Cmdlet 傳回的物件。
當您輸入使用者名稱時,會提示您輸入密碼。</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:parameter required="false" variableLength="false" globbing="false" pipelineInput="true (ByPropertyName)" position="1">
<maml:name>Id</maml:name>
<maml:description>
<maml:para>指定現有工作階段的識別碼。Enter-PSSession 會將指定的工作階段用於互動式工作階段。
若要尋找工作階段的識別碼,請使用 Get-PSSession Cmdlet。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">int</command:parameterValue>
<dev:type>
<maml:name>int</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue></dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="true (ByPropertyName)" position="named">
<maml:name>InstanceId</maml:name>
<maml:description>
<maml:para>指定現有工作階段的執行個體識別碼。Enter-PSSession 會將指定的工作階段用於互動式工作階段。
執行個體識別碼是一種 GUID。若要尋找工作階段的執行個體識別碼,請使用 Get-PSSession Cmdlet。您也可以使用 Session、Name 或 ID 參數指定現有的工作階段。或者,使用 ComputerName 參數啟動暫存工作階段。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">Guid</command:parameterValue>
<dev:type>
<maml:name>Guid</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue></dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="true (ByPropertyName)" position="named">
<maml:name>Name</maml:name>
<maml:description>
<maml:para>指定現有工作階段的好記名稱。Enter-PSSession 會將指定的工作階段用於互動式工作階段。
如果指定的名稱符合多個工作階段,命令會失敗。您也可以使用 Session、InstanceID 或 ID 參數指定現有的工作階段。或者,使用 ComputerName 參數啟動暫存工作階段。
若要建立好記的工作階段名稱,請使用 New-PSSession Cmdlet 的 Name 參數。</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>Port</maml:name>
<maml:description>
<maml:para>指定遠端電腦上要供此命令使用的網路連接埠。預設為連接埠 80 (HTTP 連接埠)。
使用其他連接埠之前,必須先於遠端電腦上設定 WinRM 接聽程式,以接聽該連接埠。請使用下列命令設定接聽程式:
1. winrm delete winrm/config/listener?Address=*+Transport=HTTP
2. winrm create winrm/config/listener?Address=*+Transport=HTTP @{Port="<連接埠號碼>"}
除非必要,否則請勿使用 Port 參數。命令中的連接埠設定適用於執行命令的所有電腦或工作階段。其他連接埠設定可能會導致無法在所有電腦上執行命令。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">int</command:parameterValue>
<dev:type>
<maml:name>int</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue></dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="true" pipelineInput="true (ByValue, ByPropertyName)" position="1">
<maml:name>Session</maml:name>
<maml:description>
<maml:para>指定要用於互動式工作階段的 Windows PowerShell 的工作階段 (PSSession)。此參數會接受工作階段物件。您也可以使用 Name、InstanceID 或 ID 參數指定 PSSession。
請輸入包含工作階段物件的變數,或者輸入建立或取得工作階段物件的命令,例如 New-PSSession 或 Get-PSSession 命令。您也可以經由管道將工作階段物件輸出至 Enter-PSSession。指定此參數時,只能提交一個 PSSession。如果所輸入的變數包含多個 PSSession,命令會失敗。
使用 Exit-PSSession 或 EXIT 關鍵字即可結束互動式工作階段,但是所建立的 PSSession 仍然開啟且可供使用。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">PSSession</command:parameterValue>
<dev:type>
<maml:name>PSSession</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>SessionOption</maml:name>
<maml:description>
<maml:para>設定工作階段的進階選項。請輸入使用 New-PSSessionOption Cmdlet 所建立的 SessionOption 物件。
如果有設定 $PSSessionOption 喜好設定變數的值,它會決定選項的預設值。否則,工作階段會使用系統預設值。
如需工作階段選項 (包括預設值) 的描述,請參閱 New-PSSessionOption。如需 $PSSessionOption 喜好設定變數的詳細資訊,請參閱 about_Preference_Variables。
</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">PSSessionOption</command:parameterValue>
<dev:type>
<maml:name>PSSessionOption</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>UseSSL</maml:name>
<maml:description>
<maml:para>使用安全通訊端層 (SSL) 通訊協定建立與遠端電腦的連線。預設不會使用 SSL,
因為 WS-Management 會將所有透過網路傳輸的 Windows PowerShell 內容加密。使用 UseSSL 時,便會透過 HTTPS 連線 (而非 HTTP 連線) 傳送資料,提供多一層防護。
如果使用此參數,但是供命令使用的連接埠無法使用 SSL,則命令會失敗。</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:parameters>
<!-- Input - Output section-->
<command:inputTypes>
<command:inputType>
<dev:type>
<maml:name>System.String 或 System.Management.Automation.Runspaces.PSSession</maml:name>
<maml:uri />
<maml:description />
</dev:type>
<maml:description>
<maml:para>
<!-- description -->
您可經由管道將電腦名稱 (字串) 或工作階段物件輸出至 Enter-PSSession。
</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>
-- 若要連線至遠端電腦,您必須是遠端電腦上 Administrators 群組的成員。
-- 在 Windows Vista 和更新版的 Windows 中,若要在本機電腦上啟動互動式工作階段,您必須以 [以系統管理員身分執行] 選項啟動 Windows PowerShell。
-- 使用 Enter-PSSession 時,您在遠端電腦上的使用者設定檔會用於互動式工作階段。執行此遠端使用者設定檔中的命令 (包括用來新增 Windows PowerShell 嵌入式管理單元及變更命令提示字元的命令) 之後,才會顯示遠端提示。
-- Enter-PSSession 會將本機電腦上的 UI 文化特性設定用於互動式工作階段。若要尋找本機 UI 文化特性,請使用 $UICulture 自動變數。
-- Enter-PSSession 需要 Get-Command、Out-Default 和 Exit-PSSession Cmdlet。如果遠端電腦上的工作階段設定不包含這些 Cmdlet,Enter-PSSession 命令會失敗。
-- 不像 Invoke-Command 先剖析及解譯命令,再將命令傳送至遠端電腦,Enter-PSSession 會直接將命令傳送至遠端電腦,而不進行解譯。
</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>
Enter-PSSession
LocalHost\PS> </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>
enter-pssession -computer Server01
Server01\PS> get-process powershell > C:\ps-test\process.txt
Server01\PS> exit-pssession
C:\PS>
C:\PS> dir C:\ps-test\process.txt
Get-ChildItem : Cannot find path 'C:\ps-test\process.txt' because it does not exist.
At line:1 char:4
+ dir <<<< c:\ps-test\process.txt
</dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個命令示範如何在互動式工作階段中與遠端電腦互動。
第一個命令會使用 Enter-PSSession Cmdlet,啟動與遠端電腦 Server01 之間的互動式工作階段。當工作階段啟動時,命令提示字元會變更為包含該電腦名稱。
第二個命令會取得 PowerShell 處理序,並將輸出重新導向至 Process.txt 檔案。從本機向遠端電腦提交此命令後,檔案便會儲存在遠端電腦上。
第三個命令會使用 Exit 關鍵字,結束互動式工作階段並關閉連線。
第四個命令可以確認 Process.txt 檔案是在遠端電腦。因為在本機電腦執行 Get-ChildItem ("dir") 命令會找不到此檔案。</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>
$s = new-pssession -computername Server01
C:\PS> Enter-PSSession -session $s
Server01\PS> </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這些命令會使用 Enter-PSSession 的 Session 參數,在現有 Windows PowerShell 工作階段 (PSSession) 中執行互動式工作階段。</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>
Enter-PSSession -computername Server01 -port 90 -credential domain01\user01
Server01\PS>
</dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個命令會啟動與 Server01 電腦之間的互動式工作階段。它使用 Port 參數指定連接埠,並使用 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>
-------------------------- 範例 5 --------------------------
</maml:title>
<maml:introduction>
<maml:para>C:\PS></maml:para>
</maml:introduction>
<dev:code>
Enter-PSSession -computername Server01
Server01:\PS> Exit-PSSession
C:\PS> </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個範例會示範如何啟動及停止互動式工作階段。第一個命令會使用 Enter-PSSession Cmdlet,啟動與 Server01 電腦之間的互動式工作階段。
第二個命令會使用 Exit-PSSession Cmdlet 結束工作階段。您也可以使用 Exit 關鍵字結束互動式工作階段。Exit-PSSession 和 Exit 的作用相同。</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=135210</maml:uri>
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>about_PSSessions</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>about_Remote</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>New-PSSession</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Get-PSSession</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Exit-PSSession</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Remove-PSSession</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Invoke-Command</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>
Exit-PSSession
</command:name>
<maml:description>
<maml:para>結束與遠端電腦之間的互動式工作階段。</maml:para>
</maml:description>
<maml:copyright>
<maml:para></maml:para>
</maml:copyright>
<command:verb>Exit</command:verb>
<command:noun>PSSession</command:noun>
<dev:version></dev:version>
</command:details>
<maml:description>
<maml:para>Exit-PSSession Cmdlet 會結束透過 Enter-PSSession 所啟動的互動式工作階段。
您也可以使用 Exit 關鍵字結束互動式工作階段,其作用與使用 Exit-PSSession 相同。</maml:para>
</maml:description>
<!-- Cmdlet syntax section-->
<command:syntax>
<command:syntaxItem>
<maml:name>Exit-PSSession</maml:name>
</command:syntaxItem>
</command:syntax>
<!-- Cmdlet parameter section -->
<command:parameters>
</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 -->
您無法經由管道將物件輸出至 Exit-PSSession。
</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>
此 Cmdlet 只接受一般參數。
</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>
Enter-PSSession -computername Server01
Server01\PS> Exit-PSSession
C:\PS> </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這些命令會啟動然後停止與 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>
-------------------------- 範例 2 --------------------------
</maml:title>
<maml:introduction>
<maml:para>C:\PS></maml:para>
</maml:introduction>
<dev:code>
$s = new-pssession -computername Server01
C:\PS> Enter-PSSession -session $s
Server01\PS> Exit-PSSession
C:\PS> $s
Id Name ComputerName State ConfigurationName
-- ---- ------------ ----- -----------------
1 Session1 Server01 Opened Microsoft.PowerShell </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這些命令會先使用 Windows PowerShell 工作階段 (PSSession) 啟動與 Server01 電腦之間的互動式工作階段,然後停止此互動式工作階段。
因為互動式工作階段是透過 Windows PowerShell 工作階段 (PSSession) 啟動,所以當互動式工作階段結束時 PSSession 仍然可供使用。如果使用 ComputerName 參數,Enter-PSSession 便會建立的暫存工作階段,而此暫存工作階段會在互動式工作階段結束時關閉。
第一個命令會使用 New-PSSession Cmdlet,在 Server01 電腦建立 PSSession,並將此 PSSession 儲存在 $s 變數中。
第二個命令會使用 Enter-PSSession Cmdlet,透過 $s 中的 PSSession 啟動互動式工作階段。
第三個命令會使用 Exit-PSSession Cmdlet 停止互動式工作階段。
最後一個命令會顯示 $s 變數中的 PSSession。State 屬性顯示 PSSession 仍然開啟,可供使用。</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>
Enter-PSSession -computername Server01
Server01\PS> exit
C:\PS> </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個命令會使用 Exit 關鍵字,停止透過 Enter-PSSession Cmdlet 所啟動的互動式工作階段。Exit 關鍵字的作用與使用 Exit-PSSession 相同。</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=135212</maml:uri>
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>about_PSSessions</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>about_Remote</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Enter-PSSession</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>New-PSSession</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Get-PSSession</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Remove-PSSession</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Invoke-Command</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>
Export-Console
</command:name>
<maml:description>
<maml:para>將目前工作階段中嵌入式管理單元的名稱匯出至主控台檔案。</maml:para>
</maml:description>
<maml:copyright>
<maml:para></maml:para>
</maml:copyright>
<command:verb>Export</command:verb>
<command:noun>Console</command:noun>
<dev:version></dev:version>
</command:details>
<maml:description>
<maml:para>Export-Console Cmdlet 會將目前工作階段中 Windows PowerShell 嵌入式管理單元的名稱匯出至 Windows PowerShell 主控台檔案 (.psc1)。您可以使用此 Cmdlet 儲存嵌入式管理單元,在未來的工作階段中使用。
若要將 .psc1 主控台檔案中的嵌入式管理單元新增至工作階段,請透過使用 Cmd.exe 或另一個 Windows PowerShell 工作階段,在命令列啟動 Windows PowerShell (PowerShell.exe),然後使用 PowerShell.exe 的 PSConsoleFile 參數指定主控台檔案。
如需 Windows PowerShell 嵌入式管理單元的詳細資訊,請參閱 about_PSSnapins。</maml:para>
</maml:description>
<!-- Cmdlet syntax section-->
<command:syntax>
<command:syntaxItem>
<maml:name>Export-Console</maml:name>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="true (ByValue, ByPropertyName)" position="1">
<maml:name>Path</maml:name>
<maml:description>
<maml:para>指定主控台檔案 (*.psc1) 的路徑和檔名。輸入路徑 (選擇性) 和名稱。不允許使用萬用字元。
如果只輸入檔名,Export-Console 會在目前目錄中建立具有該名稱和 ".psc1" 副檔名的檔案。
除非您在目前工作階段期間曾經以 PSConsoleFile 參數開啟 Windows PowerShell 或匯出主控台檔案,否則一定要指定此參數。若您使用 NoClobber 參數防止覆寫目前的主控台檔案,也必須指定此參數。
如果省略此參數,Export-Console 會覆寫目前工作階段中最近使用的主控台檔案 (取代檔案內容)。最近所使用之主控台檔案的路徑係儲存在 $ConsoleFileName 自動變數的值中。如需詳細資訊,請參閱 about_Automatic_Variables。</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>Force</maml:name>
<maml:description>
<maml:para>覆寫主控台檔案的資料而不顯示警告,即使檔案具有唯讀屬性也一樣。唯讀屬性將被變更,且命令完成後不會重設。</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>NoClobber</maml:name>
<maml:description>
<maml:para>不會覆寫 (取代) 現有主控台檔案的內容。根據預設,如果有檔案現存於指定的路徑,Export-Console 將覆寫該檔案而不顯示警告。</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="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>Force</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></dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>NoClobber</maml:name>
<maml:description>
<maml:para>不會覆寫 (取代) 現有主控台檔案的內容。根據預設,如果有檔案現存於指定的路徑,Export-Console 將覆寫該檔案而不顯示警告。</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 (ByValue, ByPropertyName)" position="1">
<maml:name>Path</maml:name>
<maml:description>
<maml:para>指定主控台檔案 (*.psc1) 的路徑和檔名。輸入路徑 (選擇性) 和名稱。不允許使用萬用字元。
如果只輸入檔名,Export-Console 會在目前目錄中建立具有該名稱和 ".psc1" 副檔名的檔案。
除非您在目前工作階段期間曾經以 PSConsoleFile 參數開啟 Windows PowerShell 或匯出主控台檔案,否則一定要指定此參數。若您使用 NoClobber 參數防止覆寫目前的主控台檔案,也必須指定此參數。
如果省略此參數,Export-Console 會覆寫目前工作階段中最近使用的主控台檔案 (取代檔案內容)。最近所使用之主控台檔案的路徑係儲存在 $ConsoleFileName 自動變數的值中。如需詳細資訊,請參閱 about_Automatic_Variables。</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 -->
您可以經由管道將路徑字串輸出至 Export-Console。
</maml:para>
</maml:description>
</command:inputType>
</command:inputTypes>
<command:returnValues>
<command:returnValue>
<dev:type>
<maml:name>System.IO.FileInfo</maml:name>
<maml:uri />
<maml:description />
</dev:type>
<maml:description>
<maml:para>
<!-- description -->
Export-Console 會建立包含匯出別名的檔案。
</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>
使用主控台檔案 (.psc1) 啟動工作階段時,主控台檔案的名稱會自動儲存在 $ConsoleFileName 自動變數中。當您使用 Export-Console 的 Path 參數指定新的主控台檔案時,便會更新 $ConsoleFileName 的值。未使用主控台檔案時,$ConsoleFileName 就沒有值 ($null)。
若要在新的工作階段中使用 Windows PowerShell 主控台檔案,請使用下列語法啟動 Windows PowerShell:
"powershell.exe -PsConsoleFile <ConsoleFile>.psc1"。
您也可以將 Add-PSSnapin 命令新增至 Windows PowerShell 設定檔,藉以儲存 Windows PowerShell 嵌入式管理單元供未來工作階段使用。如需詳細資訊,請參閱 about_Profiles。
</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>
export-console -path $pshome\Consoles\ConsoleS1.psc1 </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個命令會將目前工作階段中 Windows PowerShell 嵌入式管理單元的名稱匯出至 Windows PowerShell 安裝目錄 $pshome 之 Consoles 子目錄中的 ConsoleS1.psc1 檔案。</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>
export-console </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個命令會從目前的工作階段,將 Windows PowerShell 嵌入式管理單元的名稱匯出至目前工作階段中最近所使用的 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>
add-pssnapin NewPSSnapin
C:\PS> export-console -path NewPSSnapinConsole.psc1
C:\PS> powershell.exe -PsConsoleFile NewPsSnapinConsole.psc1 </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這些命令會將 NewPSSnapin Windows PowerShell 嵌入式管理單元新增至目前工作階段、將目前工作階段中 Windows PowerShell 嵌入式管理單元的名稱匯出至主控台檔案,再以該主控台檔案啟動 Windows PowerShell 工作階段。
第一個命令會使用 Add-PSSnapin Cmdlet 將 NewPSSnapin 嵌入式管理單元新增至目前工作階段。您只能新增系統上已註冊的 Windows PowerShell 嵌入式管理單元。
第二個命令會將 Windows PowerShell 嵌入式管理單元的名稱匯出至 NewPSSnapinConsole.psc1 檔案。
第三個命令會以 NewPSSnapinConsole.psc1 檔案啟動 Windows PowerShell。因為主控台檔案包含 Windows PowerShell 嵌入式管理單元的名稱,所以您就可以在目前工作階段中使用該嵌入式管理單元內的 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>
-------------------------- 範例 4 --------------------------
</maml:title>
<maml:introduction>
<maml:para>C:\PS></maml:para>
</maml:introduction>
<dev:code>
export-console -path Console01
C:\PS> notepad console01.psc1
<?xml version="1.0" encoding="utf-8"?>
<PSConsoleFile ConsoleSchemaVersion="1.0">
<PSVersion>2.0</PSVersion>
<PSSnapIns>
<PSSnapIn Name="NewPSSnapin" />
</PSSnapIns>
</PSConsoleFile> </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個命令會將目前工作階段中 Windows PowerShell 嵌入式管理單元的名稱匯出至目前目錄中的 Console01.psc1 檔案。
第二個命令會在 [記事本] 中顯示 Console01.psc1 檔案的內容。</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>
powershell.exe -PSConsoleFile Console01.psc1
C:\PS> add-pssnapin MySnapin
C:\PS> export-console NewConsole.psc1
C:\PS> $consolefilename
C:\PS> add-pssnapin SnapIn03
C:\PS> export-console </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>在這個範例中,會示範如何利用 $ConsoleFileName 自動變數,在您使用 Export-Console 但未指定 Path 參數值時,決定將會更新的主控台檔案。
第一個命令會使用 PowerShell.exe 的 PSConsoleFile 參數,開啟 Windows PowerShell 及 Console01.psc1 檔案。
第二個命令會使用 Add-PSSnapin Cmdlet 將 MySnapin Windows PowerShell 嵌入式管理單元新增至目前工作階段。
第三個命令會使用 Export-Console Cmdlet 將工作階段中所有 Windows PowerShell 嵌入式管理單元的名稱匯出至 NewConsole.psc1 檔案。
第四個命令會使用 $ConsoleFileName 參數,顯示最近使用的主控台檔案。範例輸出顯示 NewConsole.ps1 是最近使用的檔案。
第五個命令會將 SnapIn03 新增至目前主控台。
第六個命令會使用 ExportConsole Cmdlet 但不指定 Path 參數,將目前工作階段中所有 Windows PowerShell 嵌入式管理單元的名稱匯出至最近使用的檔案 NewConsole.psc1。
</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=113298</maml:uri>
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Add-PSSnapin</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Get-PSSnapin</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Remove-PSSnapin</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>
Export-ModuleMember
</command:name>
<maml:description>
<maml:para>指定匯出的模組成員。</maml:para>
</maml:description>
<maml:copyright>
<maml:para></maml:para>
</maml:copyright>
<command:verb>Export</command:verb>
<command:noun>ModuleMember</command:noun>
<dev:version></dev:version>
</command:details>
<maml:description>
<maml:para>Export-ModuleMember Cmdlet 會指定要從指令碼模組 (.psm1) 檔案或透過 New-Module Cmdlet 建立的動態模組中匯出的模組成員 (例如 Cmdlet、函數、變數和別名)。此 Cmdlet 只能用於指令碼模組檔案或動態模組。
如果指令碼模組不包含 Export-ModuleMember 命令,則會匯出指令碼模組中的函數,但不會匯出變數和別名。如果指令碼模組包含 Export-ModuleMember 命令,則只會匯出 Export-ModuleMember 命令中指定的成員。
如果指令碼模組包含多個 Export-ModuleMember 命令,則只會匯出 Export-ModuleMember 命令中列出的成員。
您也可以使用 Export-ModuleMember,將指令碼模組從其他模組匯入的成員匯出。</maml:para>
</maml:description>
<!-- Cmdlet syntax section-->
<command:syntax>
<command:syntaxItem>
<maml:name>Export-ModuleMember</maml:name>
<command:parameter required="false" variableLength="true" globbing="true" pipelineInput="true (ByValue, ByPropertyName)" position="1">
<maml:name>Function</maml:name>
<maml:description>
<maml:para>指定要從指令碼模組檔案匯出的函數。請輸入函數名稱。允許使用萬用字元。您也可以經由管道將函數名稱字串輸出至 Export-ModuleMember。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="true">string[]</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="true" pipelineInput="true (ByPropertyName)" position="named">
<maml:name>Alias</maml:name>
<maml:description>
<maml:para>指定要從指令碼模組檔案匯出的別名。請輸入別名。允許使用萬用字元。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="true">string[]</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="true" pipelineInput="true (ByPropertyName)" position="named">
<maml:name>Cmdlet</maml:name>
<maml:description>
<maml:para>指定要從指令碼模組檔案匯出的 Cmdlet。請輸入 Cmdlet 的名稱。允許使用萬用字元。
您無法在指令碼模組檔案中建立 Cmdlet,但可以將 Cmdlet 從二進位模組匯入至指令碼模組,然後從指令碼模組重新匯出。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="true">string[]</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="true" pipelineInput="true (ByPropertyName)" position="named">
<maml:name>Variable</maml:name>
<maml:description>
<maml:para>指定要從指令碼模組檔案匯出的變數。請輸入變數名稱 (不含貨幣符號)。允許使用萬用字元。</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="false" variableLength="true" globbing="true" pipelineInput="true (ByPropertyName)" position="named">
<maml:name>Alias</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="true" globbing="true" pipelineInput="true (ByPropertyName)" position="named">
<maml:name>Cmdlet</maml:name>
<maml:description>
<maml:para>指定要從指令碼模組檔案匯出的 Cmdlet。請輸入 Cmdlet 的名稱。允許使用萬用字元。
您無法在指令碼模組檔案中建立 Cmdlet,但可以將 Cmdlet 從二進位模組匯入至指令碼模組,然後從指令碼模組重新匯出。</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="true" pipelineInput="true (ByValue, ByPropertyName)" position="1">
<maml:name>Function</maml:name>
<maml:description>
<maml:para>指定要從指令碼模組檔案匯出的函數。請輸入函數名稱。允許使用萬用字元。您也可以經由管道將函數名稱字串輸出至 Export-ModuleMember。</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="true" pipelineInput="true (ByPropertyName)" position="named">
<maml:name>Variable</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: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 -->
您可以經由管道將函數名稱字串輸出至 Export-ModuleMember。
</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>
若要從匯出成員的清單中排除某個成員,請新增 Export-ModuleMember 命令,其中列出所有其他成員但省略要排除的成員。
</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>
Export-ModuleMember -function * -alias * </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>
Export-ModuleMember -function Get-Test, New-Test, Start-Test -alias gtt, ntt, stt </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>
Export-ModuleMember </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>
-------------------------- 範例 4 --------------------------
</maml:title>
<maml:introduction>
<maml:para>C:\PS></maml:para>
</maml:introduction>
<dev:code>
Export-ModuleMember -variable increment </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個命令只會從指令碼模組匯出 $increment 變數,而不會匯出其他成員。
除了匯出模組中的函數以外,如果您想要匯出變數,Export-ModuleMember 命令就必須包含所有函數的名稱以及變數的名稱。</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>
# From TestModule.psm1
function new-test
{ <function code> }
export-modulemember -function new-test
function validate-test
{ <function code> }
function start-test
{ <function code> }
set-alias stt start-test
export-modulemember -function *-test -alias stt </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這些命令示範如何解譯指令碼模組 (.psm1) 檔案中的多個 Export-ModuleMember 命令。
這些命令會建立三個函數和一個別名,然後匯出其中兩個函數和該別名。
如果不使用 Export-ModuleMember 命令,則會匯出所有三個函數,但不會匯出別名。如果使用 Export-ModuleMember 命令,則只會匯出 Get-Test 和 Start-Test函數,以及 STT 別名。
</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>
new-module -script {function SayHello {"Hello!"}; set-alias Hi SayHello; Export-ModuleMember -alias Hi -function SayHello} </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個命令示範如何在透過以 New-Module Cmdlet 所建立的動態模組中使用 Export-ModuleMember。
在這個範例中,Export-ModuleMember 是用來匯出動態模組中的 "Hi" 別名和 "SayHello" 函數。</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>
-------------------------- 範例 7 --------------------------
</maml:title>
<maml:introduction>
<maml:para>C:\PS></maml:para>
</maml:introduction>
<dev:code>
function export
{
param (
[parameter(mandatory=$true)] [validateset("function","variable")] $type,
[parameter(mandatory=$true)] $name,
[parameter(mandatory=$true)] $value
)
if ($type -eq "function")
{
Set-item "function:script:$name" $value
Export-ModuleMember $name
}
else
{
Set-Variable -scope Script $name $value
Export-ModuleMember -variable $name
}
}
export function New-Test
{
...
}
function helper
{
...
}
export variable interval 0
$interval = 2 </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個範例會包含名為 Export 的函數,以便宣告函數或建立變數,然後寫入該函數或變數的 Export-ModuleMember 命令。這樣做可讓您在單一命令中宣告並匯出函數或變數。
若要使用 Export 函數,請在指令碼模組中加入此函數。若要匯出函數,請在 Function 關鍵字前面輸入 "Export"。
若要匯出變數,請使用下列格式來宣告變數並設定其值:
export variable <變數名稱> <值>
此範例中的命令示範了正確的格式。在這個範例中,只會匯出 New-Test 函數和 $Interval 變數。</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=141551</maml:uri>
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Import-Module</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Get-Module</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Remove-Module</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>about_Modules</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>
ForEach-Object
</command:name>
<maml:description>
<maml:para>對輸入物件集合中的每個物件執行作業。</maml:para>
</maml:description>
<maml:copyright>
<maml:para></maml:para>
</maml:copyright>
<command:verb>ForEach</command:verb>
<command:noun>Object</command:noun>
<dev:version></dev:version>
</command:details>
<maml:description>
<maml:para>ForEach-Object Cmdlet 會對輸入物件集合中的每個物件執行作業。這些輸入物件可以傳入到此 Cmdlet,或是使用 InputObject 參數指定。
要執行的作業會描述於指令碼區塊中,而且是以 Process 參數的值提供給 Cmdlet。此指令碼區塊可以包含任何 Windows PowerShell 指令碼。
在此指令碼區塊中,目前的輸入物件會以 $_ 變數表示。
除了使用這種描述要對每個輸入物件執行之作業的指令碼區塊以外,您還可以另外提供兩種指令碼區塊。其中一種指定為 Begin 參數值的指令碼區塊,可在處理第一個輸入物件之前執行。另一種指定為 End 參數值的指令碼區塊,則可在處理最後一個輸入物件之後執行。
所有指令碼區塊 (包括使用 Begin 和 End 指定的指令碼區塊) 的評估結果都會沿著管線向下傳遞。</maml:para>
</maml:description>
<!-- Cmdlet syntax section-->
<command:syntax>
<command:syntaxItem>
<maml:name>ForEach-Object</maml:name>
<command:parameter required="true" variableLength="true" globbing="false" pipelineInput="false" position="1">
<maml:name>Process</maml:name>
<maml:description>
<maml:para>指定要套用至每個內送物件的指令碼區塊。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="true">ScriptBlock[]</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>Begin</maml:name>
<maml:description>
<maml:para>指定要在處理任何輸入物件前先執行的指令碼區塊。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">scriptblock</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>End</maml:name>
<maml:description>
<maml:para>指定要在處理所有的輸入物件後才執行的指令碼區塊。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">scriptblock</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="true (ByValue)" position="named">
<maml:name>InputObject</maml:name>
<maml:description>
<maml:para>接受物件以對其執行 process 參數所指定的指令碼區塊。請輸入包含物件的變數,或輸入可取得物件的命令或運算式。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">psobject</command:parameterValue>
</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>Begin</maml:name>
<maml:description>
<maml:para>指定要在處理任何輸入物件前先執行的指令碼區塊。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">scriptblock</command:parameterValue>
<dev:type>
<maml:name>scriptblock</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>End</maml:name>
<maml:description>
<maml:para>指定要在處理所有的輸入物件後才執行的指令碼區塊。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">scriptblock</command:parameterValue>
<dev:type>
<maml:name>scriptblock</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue></dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="true (ByValue)" position="named">
<maml:name>InputObject</maml:name>
<maml:description>
<maml:para>接受物件以對其執行 process 參數所指定的指令碼區塊。請輸入包含物件的變數,或輸入可取得物件的命令或運算式。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">psobject</command:parameterValue>
<dev:type>
<maml:name>psobject</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue></dev:defaultValue>
</command:parameter>
<command:parameter required="true" variableLength="true" globbing="false" pipelineInput="false" position="1">
<maml:name>Process</maml:name>
<maml:description>
<maml:para>指定要套用至每個內送物件的指令碼區塊。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="true">ScriptBlock[]</command:parameterValue>
<dev:type>
<maml:name>ScriptBlock[]</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.Management.Automation.PSObject</maml:name>
<maml:uri />
<maml:description />
</dev:type>
<maml:description>
<maml:para>
<!-- description -->
您可經由管道將任何物件輸出至 ForEach-Object。
</maml:para>
</maml:description>
</command:inputType>
</command:inputTypes>
<command:returnValues>
<command:returnValue>
<dev:type>
<maml:name>System.Management.Automation.PSObject</maml:name>
<maml:uri />
<maml:description />
</dev:type>
<maml:description>
<maml:para>
<!-- description -->
ForEach-Object 所傳回的物件是由輸入所決定。
</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>
30000,56798,12432 | foreach-object -process {$_/1024} </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個命令會接受整數陣列,將其中各個整數除以 1024,然後顯示結果。</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-childitem C:\ | foreach-object -process { $_.length / 1024 } </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個命令會擷取 C: 磁碟機根目錄中的檔案和目錄,然後傳回並顯示其中每個項目的大小。零值代表其中沒有可用檔案大小的目錄。</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>
$events = get-eventlog -logname system -newest 1000
C:\PS> $events | foreach-object -begin {get-date} -process {out-file -filepath events.txt -append -inputobject $_.message} -end {get-date} </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個命令會從系統記錄檔擷取 1000 個最新事件,並將它們存放在 $events 變數。接著,它會經由管道將這些事件輸出至 ForEach-Object Cmdlet。Begin 參數會顯示目前的日期和時間。接著,Process 參數會使用 Out-File Cmdlet 建立名為 events.txt 的文字檔,並將各個事件的 message 屬性存放在該檔案中。最後,在全部處理都完成之後,使用 End 參數來顯示日期和時間。</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-itemproperty -path hkcu:\Network\* | foreach-object {set-itemproperty -path $_.pspath -name RemotePath -value $_.RemotePath.ToUpper();} </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個命令會將 HKCU:\Network 機碼底下所有子機碼的 RemotePath 登錄項目值變更為大寫字母。您可以使用此格式,變更登錄項目值的格式或內容。
Network 機碼中的每個子機碼都代表登入時將會重新連接的對應網路磁碟機。RemotePath 項目包含所連接之磁碟機的 UNC 路徑。例如,如果您將 E 磁碟機對應至 \\Server\Share,則會有 HKCU:\Network 的 E 子機碼,而且 E 子機碼之 RemotePath 登錄項目的值為 \\Server\Share。
這個命令會使用 Get-ItemProperty Cmdlet 取得 Network 機碼的所有子機碼,並使用 Set-ItemProperty Cmdlet 變更每個機碼中 RemotePath 登錄項目的值。在 Set-ItemProperty 命令中,路徑是登錄機碼的 PSPath 屬性值 (這是代表登錄機碼之 Microsoft .NET Framework 物件的屬性,而不是登錄項目)。這個命令會使用 RemotePath 值的 ToUpper() 方法,也就是字串 (REG_SZ)。
因為 Set-ItemProperty 會變更每個機碼的屬性,所以需要 ForEach-Object 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:examples>
<!-- Link section -->
<maml:relatedLinks>
<maml:navigationLink>
<maml:linkText>Online version:</maml:linkText>
<maml:uri>http://go.microsoft.com/fwlink/?LinkID=113300</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-Command
</command:name>
<maml:description>
<maml:para>取得 Cmdlet 和其他 Windows PowerShell 命令元素的基本資訊。</maml:para>
</maml:description>
<maml:copyright>
<maml:para></maml:para>
</maml:copyright>
<command:verb>Get</command:verb>
<command:noun>Command</command:noun>
<dev:version></dev:version>
</command:details>
<maml:description>
<maml:para>Get-Command Cmdlet 會取得工作階段中 Cmdlet 及其他 Windows PowerShell 命令元素 (例如別名、函數、篩選、指令碼和應用程式) 的基本資訊。
Get-Command 會直接從 Cmdlet、函數、指令碼或別名的程式碼中取得資料,不像 Get-Help 是從說明主題檔案取得資訊。
如果未指定參數,"Get-Command" 會取得目前工作階段中的所有 Cmdlet 和函數。"Get-Command *" 會取得所有 Windows PowerShell 元素以及 Path 環境變數 ($env:path) 中的所有非 Windows PowerShell 檔案。它會將這些檔案歸類為「應用程式」命令類型群組。
您可以使用 Get-Command 的 Module 參數尋找已透過新增 Windows PowerShell 嵌入式管理單元或透過匯入模組,新增至工作階段的命令。</maml:para>
</maml:description>
<!-- Cmdlet syntax section-->
<command:syntax>
<command:syntaxItem>
<maml:name>Get-Command</maml:name>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="true (ByValue, ByPropertyName)" position="1">
<maml:name>Name</maml:name>
<maml:description>
<maml:para>只取得具有指定名稱的 cmdlet 或命令元素的相關資訊。<String> 代表 cmdlet 或命令元素的部分或完整名稱。允許使用萬用字元。
若要以執行順序列出名稱相同的命令,請輸入不含萬用字元的命令名稱。如需詳細資訊,請參閱<附註>一節。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="true">string[]</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="true (ByPropertyName)" position="named">
<maml:name>CommandType</maml:name>
<maml:description>
<maml:para>只取得指定的命令類型。請使用 "CommandType" 或其別名 "Type"。根據預設,Get-Command 會取得 Cmdlet 和函數。
有效的值包括:
-- Alias:目前工作階段中的所有 Windows PowerShell 別名。
-- All:所有命令類型。它的作用相當於 "get-command *"。
-- Application:Path 環境變數 ($env:path) 所列出之路徑中所有非 Windows PowerShell 的檔案,包括 .txt、.exe 和 .dll 檔案。
-- Cmdlet:目前工作階段中的 Cmdlet。預設為 "Cmdlet"。
-- ExternalScript:Path 環境變數 ($env:path) 所列出之路徑中的所有 .ps1 檔案。
-- Filter 和 Function:所有 Windows PowerShell 函數。
-- Script:目前工作階段中的指令碼區塊。</maml:para>
</maml:description>
<command:parameterValueGroup>
<command:parameterValue required="false" variableLength="false">Alias</command:parameterValue>
<command:parameterValue required="false" variableLength="false">Function</command:parameterValue>
<command:parameterValue required="false" variableLength="false">Filter</command:parameterValue>
<command:parameterValue required="false" variableLength="false">Cmdlet</command:parameterValue>
<command:parameterValue required="false" variableLength="false">ExternalScript</command:parameterValue>
<command:parameterValue required="false" variableLength="false">Application</command:parameterValue>
<command:parameterValue required="false" variableLength="false">Script</command:parameterValue>
<command:parameterValue required="false" variableLength="false">All</command:parameterValue>
</command:parameterValueGroup>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="false" position="2">
<maml:name>ArgumentList</maml:name>
<maml:description>
<maml:para>取得與指定的參數 (「引數」,例如路徑) 搭配使用的 Cmdlet 或函數的相關資訊。ArgumentList 的別名為 Args。
若要偵測當 Cmdlet 與特定提供者搭配使用時新增至此 Cmdlet 的參數,請將 ArgumentList 的值設為提供者磁碟機中的路徑,例如 "HKML\Software" 或 "cert:\my"。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="true">Object[]</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="true (ByPropertyName)" position="named">
<maml:name>Module</maml:name>
<maml:description>
<maml:para>取得來自指定之模組或嵌入式管理單元的命令。請輸入模組或嵌入式管理單元的名稱,或輸入嵌入式管理單元或模組物件。
您可以利用此參數的名稱 (Module) 或別名 (PSSnapin) 來參照此參數。所選擇的參數名稱不會影響此命令或其輸出。
雖然這個參數會採用字串值,不過您也可以提供 PSModuleInfo 或 PSSnapinInfo 物件,例如 Get-Module、Get-PSSnapin 和 Import-PSSession 所傳回的物件。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="true">string[]</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="true (ByPropertyName)" position="named">
<maml:name>Syntax</maml:name>
<maml:description>
<maml:para>只擷取命令元素的指定資料。
* 對於別名,會擷取標準名稱。
* 對於 cmdlet,會擷取語法。
* 對於函數和篩選器,會擷取函數定義。
* 對於指令碼和應用程式 (檔案),會擷取路徑和檔名。</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="true (ByPropertyName)" position="named">
<maml:name>TotalCount</maml:name>
<maml:description>
<maml:para>只取得指定數目的命令元素。您可以使用此參數限制命令的輸出。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">int</command:parameterValue>
</command:parameter>
</command:syntaxItem>
<command:syntaxItem>
<maml:name>Get-Command</maml:name>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="true (ByPropertyName)" position="named">
<maml:name>Noun</maml:name>
<maml:description>
<maml:para>取得名稱中包含指定之名詞的 Cmdlet 和函數。<String> 代表一或多個名詞或名詞模式,例如 "process" 或 "*item*"。允許使用萬用字元。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="true">string[]</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="true (ByPropertyName)" position="named">
<maml:name>Verb</maml:name>
<maml:description>
<maml:para>取得名稱中包含指定動詞之 Cmdlet 和函數的相關資訊。<String> 代表一或多個動詞或動詞模式,例如 "remove" 或 "*et"。允許使用萬用字元。</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="2">
<maml:name>ArgumentList</maml:name>
<maml:description>
<maml:para>取得與指定的參數 (「引數」,例如路徑) 搭配使用的 Cmdlet 或函數的相關資訊。ArgumentList 的別名為 Args。
若要偵測當 Cmdlet 與特定提供者搭配使用時新增至此 Cmdlet 的參數,請將 ArgumentList 的值設為提供者磁碟機中的路徑,例如 "HKML\Software" 或 "cert:\my"。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="true">Object[]</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="true (ByPropertyName)" position="named">
<maml:name>Module</maml:name>
<maml:description>
<maml:para>取得來自指定之模組或嵌入式管理單元的命令。請輸入模組或嵌入式管理單元的名稱,或輸入嵌入式管理單元或模組物件。
您可以利用此參數的名稱 (Module) 或別名 (PSSnapin) 來參照此參數。所選擇的參數名稱不會影響此命令或其輸出。
雖然這個參數會採用字串值,不過您也可以提供 PSModuleInfo 或 PSSnapinInfo 物件,例如 Get-Module、Get-PSSnapin 和 Import-PSSession 所傳回的物件。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="true">string[]</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="true (ByPropertyName)" position="named">
<maml:name>Syntax</maml:name>
<maml:description>
<maml:para>只擷取命令元素的指定資料。
* 對於別名,會擷取標準名稱。
* 對於 cmdlet,會擷取語法。
* 對於函數和篩選器,會擷取函數定義。
* 對於指令碼和應用程式 (檔案),會擷取路徑和檔名。</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="true (ByPropertyName)" position="named">
<maml:name>TotalCount</maml:name>
<maml:description>
<maml:para>只取得指定數目的命令元素。您可以使用此參數限制命令的輸出。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">int</command:parameterValue>
</command:parameter>
</command:syntaxItem>
</command:syntax>
<!-- Cmdlet parameter section -->
<command:parameters>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="false" position="2">
<maml:name>ArgumentList</maml:name>
<maml:description>
<maml:para>取得與指定的參數 (「引數」,例如路徑) 搭配使用的 Cmdlet 或函數的相關資訊。ArgumentList 的別名為 Args。
若要偵測當 Cmdlet 與特定提供者搭配使用時新增至此 Cmdlet 的參數,請將 ArgumentList 的值設為提供者磁碟機中的路徑,例如 "HKML\Software" 或 "cert:\my"。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="true">Object[]</command:parameterValue>
<dev:type>
<maml:name>Object[]</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue></dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="true (ByPropertyName)" position="named">
<maml:name>CommandType</maml:name>
<maml:description>
<maml:para>只取得指定的命令類型。請使用 "CommandType" 或其別名 "Type"。根據預設,Get-Command 會取得 Cmdlet 和函數。
有效的值包括:
-- Alias:目前工作階段中的所有 Windows PowerShell 別名。
-- All:所有命令類型。它的作用相當於 "get-command *"。
-- Application:Path 環境變數 ($env:path) 所列出之路徑中所有非 Windows PowerShell 的檔案,包括 .txt、.exe 和 .dll 檔案。
-- Cmdlet:目前工作階段中的 Cmdlet。預設為 "Cmdlet"。
-- ExternalScript:Path 環境變數 ($env:path) 所列出之路徑中的所有 .ps1 檔案。
-- Filter 和 Function:所有 Windows PowerShell 函數。
-- Script:目前工作階段中的指令碼區塊。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">CommandTypes</command:parameterValue>
<dev:type>
<maml:name>CommandTypes</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue></dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="true (ByPropertyName)" position="named">
<maml:name>Module</maml:name>
<maml:description>
<maml:para>取得來自指定之模組或嵌入式管理單元的命令。請輸入模組或嵌入式管理單元的名稱,或輸入嵌入式管理單元或模組物件。
您可以利用此參數的名稱 (Module) 或別名 (PSSnapin) 來參照此參數。所選擇的參數名稱不會影響此命令或其輸出。
雖然這個參數會採用字串值,不過您也可以提供 PSModuleInfo 或 PSSnapinInfo 物件,例如 Get-Module、Get-PSSnapin 和 Import-PSSession 所傳回的物件。</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>Name</maml:name>
<maml:description>
<maml:para>只取得具有指定名稱的 cmdlet 或命令元素的相關資訊。<String> 代表 cmdlet 或命令元素的部分或完整名稱。允許使用萬用字元。
若要以執行順序列出名稱相同的命令,請輸入不含萬用字元的命令名稱。如需詳細資訊,請參閱<附註>一節。</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 (ByPropertyName)" position="named">
<maml:name>Noun</maml:name>
<maml:description>
<maml:para>取得名稱中包含指定之名詞的 Cmdlet 和函數。<String> 代表一或多個名詞或名詞模式,例如 "process" 或 "*item*"。允許使用萬用字元。</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="true (ByPropertyName)" position="named">
<maml:name>Syntax</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="false" variableLength="false" globbing="false" pipelineInput="true (ByPropertyName)" position="named">
<maml:name>TotalCount</maml:name>
<maml:description>
<maml:para>只取得指定數目的命令元素。您可以使用此參數限制命令的輸出。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">int</command:parameterValue>
<dev:type>
<maml:name>int</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue></dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="true (ByPropertyName)" position="named">
<maml:name>Verb</maml:name>
<maml:description>
<maml:para>取得名稱中包含指定動詞之 Cmdlet 和函數的相關資訊。<String> 代表一或多個動詞或動詞模式,例如 "remove" 或 "*et"。允許使用萬用字元。</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-Command。
</maml:para>
</maml:description>
</command:inputType>
</command:inputTypes>
<command:returnValues>
<command:returnValue>
<dev:type>
<maml:name>Object
</maml:name>
<maml:uri />
<maml:description />
</dev:type>
<maml:description>
<maml:para>
<!-- description -->
傳回的物件類型會依擷取到的命令元素類型而定。例如,Cmdlet 上的 Get-Command 會擷取 CmdletInfo 物件,而 DLL 上的 Get-Command 會擷取 ApplicationInfo 物件。
</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-Command" 就會取得 Windows PowerShell 之 Cmdlet 和函數的相關資訊。使用參數來限定所擷取的元素。
不像 Get-Help 顯示 XML 說明主題檔案的內容,Get-Command 會直接從系統中的 Cmdlet 程式碼中取得 Cmdlet 資訊。
Get-Command 會按照字母順序傳回這些命令。當工作階段包含多個具有相同名稱的命令時,Get-Command 就會按照執行順序傳回這些命令。第一個列出的命令是當您輸入不含限定性條件的命令名稱時所執行的命令。如需詳細資訊,請參閱 about_Command_Precedence。
</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-command </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個命令會取得所有 Windows PowerShell Cmdlet 和函數的相關資訊。
預設顯示會列出命令類型 ("Cmdlet"、「函數」或「篩選」)、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>
-------------------------- 範例 2 --------------------------
</maml:title>
<maml:introduction>
<maml:para>C:\PS></maml:para>
</maml:introduction>
<dev:code>
get-command -verb set | format-list </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個命令會取得所有具有動詞 "set" 之 Cmdlet 和函數的相關資訊,並以清單方式顯示其中部分資訊。
清單格式會包含資料表顯示所省略的欄位,包括完整的語法。若要顯示所有欄位 (物件的所有屬性),請輸入 "get-command -verb set | 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:example>
<maml:title>
-------------------------- 範例 3 --------------------------
</maml:title>
<maml:introduction>
<maml:para>C:\PS></maml:para>
</maml:introduction>
<dev:code>
get-command -type cmdlet | sort-object noun | format-table -group noun </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個命令會擷取所有的 Cmdlet,並依 Cmdlet 名稱的英文字母順序來排序,然後將它們顯示成以名詞為主的
群組。這種顯示方式有助於尋找某項工作的 Cmdlet。
根據預設,Get-Command 會依照系統找到項目的順序來顯示這些項目;在執行命令不明確時,也會依照這個順序來選取要執行的項目。</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-command -module Microsoft.PowerShell.Security, TestModule </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個命令會取得 Microsoft.PowerShell.Security 嵌入式管理單元和 Test-Module 模組中的命令。
Module 參數會取得透過匯入模組或新增 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>
-------------------------- 範例 5 --------------------------
</maml:title>
<maml:introduction>
<maml:para>C:\PS></maml:para>
</maml:introduction>
<dev:code>
get-command get-childitem -args cert: -syntax </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個命令會在 Get-ChildItem 和 Windows PowerShell Certificate 提供者一起使用時擷取 Get-ChildItem Cmdlet 的相關資訊。
如果比較輸出所顯示的語法和省略 Args (ArgumentList) 參數時所顯示的語法,您會發現到,Certificate 提供者以動態方式在 Get-ChildItem Cmdlet 中新增 CodeSigningCert 參數。</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>
(get-command get-childitem -ArgumentList cert:).parametersets[0].parameters | where-object { $_.IsDynamic } </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個命令只會擷取當 Get-ChildItem Cmdlet 與 Windows PowerShell Certificate 提供者一起使用時以動態方式新增到此 Cmdlet 的參數。這是上一個範例中所用方法的另一項選擇。
在這個命令中,"get-command get-childitem -ArgumentList cert:" 會優先處理。與 Certificate 提供者搭配使用時,它會向 Get-Command 要求 Get-ChildItem Cmdlet 的相關資訊。".parametersets[0]" 會選取 "get-childitem -argumentList cert:" 的第一個參數集 (set 0),而 ".parameters" 會選取該參數集中的參數。結果中的參數會經由管道輸出至 Where-Object Cmdlet,以便利用 IsDynamic 屬性測試每個參數 ("$_.")。若要找出命令中物件的屬性,請使用 Get-Member。</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>
-------------------------- 範例 7 --------------------------
</maml:title>
<maml:introduction>
<maml:para>C:\PS></maml:para>
</maml:introduction>
<dev:code>
get-command * </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個命令會取得目前主控台中 Windows PowerShell 的 Cmdlet、函數、篩選、指令碼和別名的相關資訊。
它也會取得 Path 環境變數 ($env:path) 之路徑中所有檔案的相關資訊。它會傳回每個檔案的 ApplicationInfo 物件 (System.Management.Automation.ApplicationInfo),而不是 FileInfo 物件 (System.IO.FileInfo)。</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>
-------------------------- 範例 8 --------------------------
</maml:title>
<maml:introduction>
<maml:para>C:\PS></maml:para>
</maml:introduction>
<dev:code>
get-command | where-object {$_.definition -like "*first*"}
CommandType Name Definition
----------- ---- ---------
Cmdlet Select-Object Select-Object [[-Property] </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個命令會根據 Cmdlet 或函數的其中一個參數名稱,搜尋該 Cmdlet 或函數。當您只記得 Cmdlet 或函數的其中一個參數名稱時,您可以使用這個命令識別該 Cmdlet 或函數。
在此例中,您記得其中一個 Cmdlet 或函數有 First 參數,可取得清單中的前 "n" 個物件,但不記得是哪個 Cmdlet。
這個命令會使用 Get-Command Cmdlet 取得代表工作階段中每個 Cmdlet 和函數的 CmdletInfo 物件。CmdletInfo 物件具有 Definition 屬性,其中包含 Cmdlet 或函數的語法,語法中則包含此 Cmdlet 或函數的參數。
這個命令會使用管線運算子 (|) 將 CmdletInfo 物件傳遞至 Where-Object Cmdlet,此 Cmdlet 會檢查每個物件 ($_) 的定義 (語法) 是否有包含 "first" 的值。
結果顯示 First 參數屬於 Select-Object 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>
-------------------------- 範例 9 --------------------------
</maml:title>
<maml:introduction>
<maml:para>C:\PS></maml:para>
</maml:introduction>
<dev:code>
get-command dir | format-list
Name : dir
CommandType : Alias
Definition : Get-ChildItem
ReferencedCommand : Get-ChildItem
ResolvedCommand : Get-ChildItem </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>在這個範例中,會示範如何搭配別名使用 Get-Command Cmdlet。儘管 Get-Command 通常用於 Cmdlet,但它也會顯示指令碼、函數、別名和可執行檔中的程式碼資訊。
這個命令會顯示目前主控台中的 "dir" 別名,然後經由管道將結果輸出至 Format-List 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>
-------------------------- 範例 10 --------------------------
</maml:title>
<maml:introduction>
<maml:para>C:\PS></maml:para>
</maml:introduction>
<dev:code>
get-command notepad
CommandType Name Definition
----------- ---- ----------
Application notepad.exe C:\WINDOWS\system32\notepad.exe
Application NOTEPAD.EXE C:\WINDOWS\NOTEPAD.EXE </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>在這個範例中,會示範如何使用 Get-Command 判斷當 Windows PowerShell 存取多個名稱相同的命令時,要執行哪個命令。使用不含萬用字元的 Name 參數時,Get-Command 會依執行優先順序列出具有該名稱的命令。
這個命令顯示當您輸入不含完整路徑的 "Notepad" 時,Windows PowerShell 會執行哪個 Notepad 程式。這個命令會使用不含萬用字元的 Name 參數。
範例輸出會顯示目前主控台中的 Notepad 命令,其中指出 Windows PowerShell 會執行 C:\Windows\System32 目錄中的 Notepad.exe 執行個體。</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>
-------------------------- 範例 11 --------------------------
</maml:title>
<maml:introduction>
<maml:para>C:\PS></maml:para>
</maml:introduction>
<dev:code>
(get-command get-date).pssnapin
C:\PS> (get-command remove-gpo).module
</dev:code>
<dev:remarks>
<maml:para>說明</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這些命令示範如何尋找特定 Cmdlet 的來源嵌入式管理單元或模組。
第一個命令會使用 CmdletInfo 物件的 PSSnapin 屬性,尋找已新增 Get-Date Cmdlet 的嵌入式管理單元。
第二個命令會使用 CmdletInfo 物件的 Module 屬性,尋找已新增 Remove-GPO 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:examples>
<!-- Link section -->
<maml:relatedLinks>
<maml:navigationLink>
<maml:linkText>Online version:</maml:linkText>
<maml:uri>http://go.microsoft.com/fwlink/?LinkID=113309</maml:uri>
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>about_Command_Precedence</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Get-Help</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Get-PSDrive</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Get-Member</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Import-PSSession</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Export-PSSession</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-Help
</command:name>
<maml:description>
<maml:para>顯示 Windows PowerShell 命令和概念的相關資訊。</maml:para>
</maml:description>
<maml:copyright>
<maml:para></maml:para>
</maml:copyright>
<command:verb>Get</command:verb>
<command:noun>Help</command:noun>
<dev:version></dev:version>
</command:details>
<maml:description>
<maml:para>Get-Help Cmdlet 會顯示 Windows PowerShell 概念和命令的相關資訊,包括 Cmdlet、提供者、函數和指令碼。若要取得所有 Cmdlet 說明主題標題的清單,請輸入 "get-help *"。
如果您輸入 "Get-Help" 後面接著說明主題的確切名稱或特有文字,Get-Help 就會顯示該主題的內容。如果您輸入出現於數個說明主題的某一文字或文字模式,則 Get-Help 會列出所有符合的標題。如果您輸入的文字未出現在任一說明主題標題中,則 Get-Help 會列出其中內容包含該特定文字的主題。
除了 "get-help" 以外,您也可以輸入 "help" 或 "man" (一次顯示一頁文字),或輸入 "<Cmdlet 名稱> -?" (其作用與 Get-Help 相同,不過僅適用於 Cmdlet)。
您可以顯示整個說明檔案或選定的檔案部分,例如語法、參數或範例。您也可以使用 Online 參數,在網際網路瀏覽器中顯示說明檔案的線上版本。這些參數對於概念性說明主題沒有作用。
Windows PowerShell 中的概念性說明主題會以 "about_" 為開頭,例如 "about_Comparison_Operators"。若要檢視所有 "about_" 主題,請輸入 "get-help about_*"。若要查看特定主題,請輸入 "get-help about_<topic-name>",例如 "get-help about_Comparison_Operators"。</maml:para>
</maml:description>
<!-- Cmdlet syntax section-->
<command:syntax>
<command:syntaxItem>
<maml:name>Get-Help</maml:name>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>Full</maml:name>
<maml:description>
<maml:para>顯示 Cmdlet 的整個說明檔案,包含參數說明和屬性、範例、輸入和輸出物件類型,以及其他附註。
此參數不會影響概念 ("About_") 說明所顯示的內容。</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="true (ByPropertyName)" position="1">
<maml:name>Name</maml:name>
<maml:description>
<maml:para>要求指定之工具或概念性主題的相關說明。請輸入 Cmdlet、提供者、指令碼或函數名稱,例如 Get-Member、概念性主題名稱 (如 "about_Objects") 或別名 (如 "ls")。雖然您可以在 Cmdlet 和提供者名稱中使用萬用字元,但是無法使用萬用字元來尋找函數說明及指令碼說明主題的名稱。
若要為不在 Path 環境變數所列之路徑的指令碼取得說明,請輸入該指令碼的路徑和檔案名稱。
如果您輸入說明主題的確切名稱,則 Get-Help 會顯示該主題的內容。如果您輸入出現於數個說明主題的某一文字或文字模式,則 Get-Help 會列出所有符合的標題。如果您輸入不符合任一說明主題標題的文字,則 Get-Help 會列出其中內容包含該特定文字的主題。
概念性主題 (例如 about_Objects) 的名稱必須以英文輸入,甚至是非英文版的 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>Category</maml:name>
<maml:description>
<maml:para>顯示指定類別中的項目相關說明。有效值為 Alias、Cmdlet、Provider 和 HelpFile。概念性主題屬於 HelpFile 類別。
Category 是 Get-Help 傳回之 MamlCommandHelpInfo 物件的屬性。此參數不會影響概念性 ("about_") 說明所顯示的內容。</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>Component</maml:name>
<maml:description>
<maml:para>顯示具有指定之元件值 (如 "Exchange") 的工具清單。請輸入元件名稱。允許使用萬用字元。
Component 是 Get-Help 傳回之 MamlCommandHelpInfo 物件的屬性。此參數不會影響概念 ("About_") 說明所顯示的內容。</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>Functionality</maml:name>
<maml:description>
<maml:para>顯示具有指定之功能的項目說明。請輸入功能。允許使用萬用字元。
Functionality 是 Get-Help 傳回之 MamlCommandHelpInfo 物件的屬性。此參數不會影響概念 ("About_") 說明所顯示的內容。</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>Online</maml:name>
<maml:description>
<maml:para>以預設的網際網路瀏覽器顯示說明主題的線上版本。此參數只適用於 Cmdlet、函數和指令碼說明主題。
Get-Help 會使用出現在 Cmdlet、函數或指令碼說明主題的<相關連結>一節之第一個項目中的網際網路位址 (統一資源識別項 [URI])。此參數只有當說明主題包含開頭為 "Http" 或 "Https" 的 URI,而且系統上已安裝網際網路瀏覽器時才有效。
如需在您所撰寫之說明主題中支援此功能的詳細資訊,請參閱 about_Comment_Based_Help,並參閱 MSDN (Microsoft Developer Network) Library 中的<如何撰寫 Cmdlet 說明>(英文),網址為 http://go.microsoft.com/fwlink/?LinkID=123415。</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>Path</maml:name>
<maml:description>
<maml:para>取得說明 Cmdlet 如何在指定之提供者路徑中運作的說明。請輸入 Windows PowerShell 提供者路徑。
此參數會取得 Cmdlet 說明主題的自訂版本,說明 Cmdlet 在指定之 Windows PowerShell 提供者路徑中的運作方式。此參數只對提供者 Cmdlet 的說明有效,並且只有當提供者包含提供者 Cmdlet 說明主題的自訂版本時才會生效。
若要查看某個提供者路徑的自訂 Cmdlet 說明,請移至該提供者路徑後再輸入 Get-Help 命令,或是從任一路徑位置使用 Get-Help 的 Path 參數指定提供者路徑。如需詳細資訊,請參閱 about_Providers。</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>Role</maml:name>
<maml:description>
<maml:para>顯示指定的使用者角色的自訂化說明。請輸入角色。允許使用萬用字元。
請輸入使用者在組織中扮演的角色。某些 cmdlet 會依據此參數的值,在其說明檔中顯示不同的文字。核心 cmdlet 的說明內容不會受到此參數所影響。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="true">string[]</command:parameterValue>
</command:parameter>
</command:syntaxItem>
<command:syntaxItem>
<maml:name>Get-Help</maml:name>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>Detailed</maml:name>
<maml:description>
<maml:para>將參數描述和範例新增至基本說明顯示。
此參數不會影響概念 ("About_") 說明所顯示的內容。</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="true (ByPropertyName)" position="1">
<maml:name>Name</maml:name>
<maml:description>
<maml:para>要求指定之工具或概念性主題的相關說明。請輸入 Cmdlet、提供者、指令碼或函數名稱,例如 Get-Member、概念性主題名稱 (如 "about_Objects") 或別名 (如 "ls")。雖然您可以在 Cmdlet 和提供者名稱中使用萬用字元,但是無法使用萬用字元來尋找函數說明及指令碼說明主題的名稱。
若要為不在 Path 環境變數所列之路徑的指令碼取得說明,請輸入該指令碼的路徑和檔案名稱。
如果您輸入說明主題的確切名稱,則 Get-Help 會顯示該主題的內容。如果您輸入出現於數個說明主題的某一文字或文字模式,則 Get-Help 會列出所有符合的標題。如果您輸入不符合任一說明主題標題的文字,則 Get-Help 會列出其中內容包含該特定文字的主題。
概念性主題 (例如 about_Objects) 的名稱必須以英文輸入,甚至是非英文版的 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>Category</maml:name>
<maml:description>
<maml:para>顯示指定類別中的項目相關說明。有效值為 Alias、Cmdlet、Provider 和 HelpFile。概念性主題屬於 HelpFile 類別。
Category 是 Get-Help 傳回之 MamlCommandHelpInfo 物件的屬性。此參數不會影響概念性 ("about_") 說明所顯示的內容。</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>Component</maml:name>
<maml:description>
<maml:para>顯示具有指定之元件值 (如 "Exchange") 的工具清單。請輸入元件名稱。允許使用萬用字元。
Component 是 Get-Help 傳回之 MamlCommandHelpInfo 物件的屬性。此參數不會影響概念 ("About_") 說明所顯示的內容。</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>Functionality</maml:name>
<maml:description>
<maml:para>顯示具有指定之功能的項目說明。請輸入功能。允許使用萬用字元。
Functionality 是 Get-Help 傳回之 MamlCommandHelpInfo 物件的屬性。此參數不會影響概念 ("About_") 說明所顯示的內容。</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>Online</maml:name>
<maml:description>
<maml:para>以預設的網際網路瀏覽器顯示說明主題的線上版本。此參數只適用於 Cmdlet、函數和指令碼說明主題。
Get-Help 會使用出現在 Cmdlet、函數或指令碼說明主題的<相關連結>一節之第一個項目中的網際網路位址 (統一資源識別項 [URI])。此參數只有當說明主題包含開頭為 "Http" 或 "Https" 的 URI,而且系統上已安裝網際網路瀏覽器時才有效。
如需在您所撰寫之說明主題中支援此功能的詳細資訊,請參閱 about_Comment_Based_Help,並參閱 MSDN (Microsoft Developer Network) Library 中的<如何撰寫 Cmdlet 說明>(英文),網址為 http://go.microsoft.com/fwlink/?LinkID=123415。</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>Path</maml:name>
<maml:description>
<maml:para>取得說明 Cmdlet 如何在指定之提供者路徑中運作的說明。請輸入 Windows PowerShell 提供者路徑。
此參數會取得 Cmdlet 說明主題的自訂版本,說明 Cmdlet 在指定之 Windows PowerShell 提供者路徑中的運作方式。此參數只對提供者 Cmdlet 的說明有效,並且只有當提供者包含提供者 Cmdlet 說明主題的自訂版本時才會生效。
若要查看某個提供者路徑的自訂 Cmdlet 說明,請移至該提供者路徑後再輸入 Get-Help 命令,或是從任一路徑位置使用 Get-Help 的 Path 參數指定提供者路徑。如需詳細資訊,請參閱 about_Providers。</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>Role</maml:name>
<maml:description>
<maml:para>顯示指定的使用者角色的自訂化說明。請輸入角色。允許使用萬用字元。
請輸入使用者在組織中扮演的角色。某些 cmdlet 會依據此參數的值,在其說明檔中顯示不同的文字。核心 cmdlet 的說明內容不會受到此參數所影響。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="true">string[]</command:parameterValue>
</command:parameter>
</command:syntaxItem>
<command:syntaxItem>
<maml:name>Get-Help</maml:name>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>Examples</maml:name>
<maml:description>
<maml:para>只顯示名稱、概要和範例。若只要顯示範例,請輸入 "(get-help <Cmdlet 名稱>).examples"。
此參數不會影響概念 ("About_") 說明所顯示的內容。</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="true (ByPropertyName)" position="1">
<maml:name>Name</maml:name>
<maml:description>
<maml:para>要求指定之工具或概念性主題的相關說明。請輸入 Cmdlet、提供者、指令碼或函數名稱,例如 Get-Member、概念性主題名稱 (如 "about_Objects") 或別名 (如 "ls")。雖然您可以在 Cmdlet 和提供者名稱中使用萬用字元,但是無法使用萬用字元來尋找函數說明及指令碼說明主題的名稱。
若要為不在 Path 環境變數所列之路徑的指令碼取得說明,請輸入該指令碼的路徑和檔案名稱。
如果您輸入說明主題的確切名稱,則 Get-Help 會顯示該主題的內容。如果您輸入出現於數個說明主題的某一文字或文字模式,則 Get-Help 會列出所有符合的標題。如果您輸入不符合任一說明主題標題的文字,則 Get-Help 會列出其中內容包含該特定文字的主題。
概念性主題 (例如 about_Objects) 的名稱必須以英文輸入,甚至是非英文版的 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>Category</maml:name>
<maml:description>
<maml:para>顯示指定類別中的項目相關說明。有效值為 Alias、Cmdlet、Provider 和 HelpFile。概念性主題屬於 HelpFile 類別。
Category 是 Get-Help 傳回之 MamlCommandHelpInfo 物件的屬性。此參數不會影響概念性 ("about_") 說明所顯示的內容。</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>Component</maml:name>
<maml:description>
<maml:para>顯示具有指定之元件值 (如 "Exchange") 的工具清單。請輸入元件名稱。允許使用萬用字元。
Component 是 Get-Help 傳回之 MamlCommandHelpInfo 物件的屬性。此參數不會影響概念 ("About_") 說明所顯示的內容。</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>Functionality</maml:name>
<maml:description>
<maml:para>顯示具有指定之功能的項目說明。請輸入功能。允許使用萬用字元。
Functionality 是 Get-Help 傳回之 MamlCommandHelpInfo 物件的屬性。此參數不會影響概念 ("About_") 說明所顯示的內容。</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>Online</maml:name>
<maml:description>
<maml:para>以預設的網際網路瀏覽器顯示說明主題的線上版本。此參數只適用於 Cmdlet、函數和指令碼說明主題。
Get-Help 會使用出現在 Cmdlet、函數或指令碼說明主題的<相關連結>一節之第一個項目中的網際網路位址 (統一資源識別項 [URI])。此參數只有當說明主題包含開頭為 "Http" 或 "Https" 的 URI,而且系統上已安裝網際網路瀏覽器時才有效。
如需在您所撰寫之說明主題中支援此功能的詳細資訊,請參閱 about_Comment_Based_Help,並參閱 MSDN (Microsoft Developer Network) Library 中的<如何撰寫 Cmdlet 說明>(英文),網址為 http://go.microsoft.com/fwlink/?LinkID=123415。</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>Path</maml:name>
<maml:description>
<maml:para>取得說明 Cmdlet 如何在指定之提供者路徑中運作的說明。請輸入 Windows PowerShell 提供者路徑。
此參數會取得 Cmdlet 說明主題的自訂版本,說明 Cmdlet 在指定之 Windows PowerShell 提供者路徑中的運作方式。此參數只對提供者 Cmdlet 的說明有效,並且只有當提供者包含提供者 Cmdlet 說明主題的自訂版本時才會生效。
若要查看某個提供者路徑的自訂 Cmdlet 說明,請移至該提供者路徑後再輸入 Get-Help 命令,或是從任一路徑位置使用 Get-Help 的 Path 參數指定提供者路徑。如需詳細資訊,請參閱 about_Providers。</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>Role</maml:name>
<maml:description>
<maml:para>顯示指定的使用者角色的自訂化說明。請輸入角色。允許使用萬用字元。
請輸入使用者在組織中扮演的角色。某些 cmdlet 會依據此參數的值,在其說明檔中顯示不同的文字。核心 cmdlet 的說明內容不會受到此參數所影響。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="true">string[]</command:parameterValue>
</command:parameter>
</command:syntaxItem>
<command:syntaxItem>
<maml:name>Get-Help</maml:name>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>Parameter</maml:name>
<maml:description>
<maml:para>只顯示指定之參數的詳細描述。允許使用萬用字元。
此參數不會影響概念 ("About_") 說明所顯示的內容。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">string</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="true (ByPropertyName)" position="1">
<maml:name>Name</maml:name>
<maml:description>
<maml:para>要求指定之工具或概念性主題的相關說明。請輸入 Cmdlet、提供者、指令碼或函數名稱,例如 Get-Member、概念性主題名稱 (如 "about_Objects") 或別名 (如 "ls")。雖然您可以在 Cmdlet 和提供者名稱中使用萬用字元,但是無法使用萬用字元來尋找函數說明及指令碼說明主題的名稱。
若要為不在 Path 環境變數所列之路徑的指令碼取得說明,請輸入該指令碼的路徑和檔案名稱。
如果您輸入說明主題的確切名稱,則 Get-Help 會顯示該主題的內容。如果您輸入出現於數個說明主題的某一文字或文字模式,則 Get-Help 會列出所有符合的標題。如果您輸入不符合任一說明主題標題的文字,則 Get-Help 會列出其中內容包含該特定文字的主題。
概念性主題 (例如 about_Objects) 的名稱必須以英文輸入,甚至是非英文版的 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>Category</maml:name>
<maml:description>
<maml:para>顯示指定類別中的項目相關說明。有效值為 Alias、Cmdlet、Provider 和 HelpFile。概念性主題屬於 HelpFile 類別。
Category 是 Get-Help 傳回之 MamlCommandHelpInfo 物件的屬性。此參數不會影響概念性 ("about_") 說明所顯示的內容。</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>Component</maml:name>
<maml:description>
<maml:para>顯示具有指定之元件值 (如 "Exchange") 的工具清單。請輸入元件名稱。允許使用萬用字元。
Component 是 Get-Help 傳回之 MamlCommandHelpInfo 物件的屬性。此參數不會影響概念 ("About_") 說明所顯示的內容。</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>Functionality</maml:name>
<maml:description>
<maml:para>顯示具有指定之功能的項目說明。請輸入功能。允許使用萬用字元。
Functionality 是 Get-Help 傳回之 MamlCommandHelpInfo 物件的屬性。此參數不會影響概念 ("About_") 說明所顯示的內容。</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>Online</maml:name>
<maml:description>
<maml:para>以預設的網際網路瀏覽器顯示說明主題的線上版本。此參數只適用於 Cmdlet、函數和指令碼說明主題。
Get-Help 會使用出現在 Cmdlet、函數或指令碼說明主題的<相關連結>一節之第一個項目中的網際網路位址 (統一資源識別項 [URI])。此參數只有當說明主題包含開頭為 "Http" 或 "Https" 的 URI,而且系統上已安裝網際網路瀏覽器時才有效。
如需在您所撰寫之說明主題中支援此功能的詳細資訊,請參閱 about_Comment_Based_Help,並參閱 MSDN (Microsoft Developer Network) Library 中的<如何撰寫 Cmdlet 說明>(英文),網址為 http://go.microsoft.com/fwlink/?LinkID=123415。</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>Path</maml:name>
<maml:description>
<maml:para>取得說明 Cmdlet 如何在指定之提供者路徑中運作的說明。請輸入 Windows PowerShell 提供者路徑。
此參數會取得 Cmdlet 說明主題的自訂版本,說明 Cmdlet 在指定之 Windows PowerShell 提供者路徑中的運作方式。此參數只對提供者 Cmdlet 的說明有效,並且只有當提供者包含提供者 Cmdlet 說明主題的自訂版本時才會生效。
若要查看某個提供者路徑的自訂 Cmdlet 說明,請移至該提供者路徑後再輸入 Get-Help 命令,或是從任一路徑位置使用 Get-Help 的 Path 參數指定提供者路徑。如需詳細資訊,請參閱 about_Providers。</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>Role</maml:name>
<maml:description>
<maml:para>顯示指定的使用者角色的自訂化說明。請輸入角色。允許使用萬用字元。
請輸入使用者在組織中扮演的角色。某些 cmdlet 會依據此參數的值,在其說明檔中顯示不同的文字。核心 cmdlet 的說明內容不會受到此參數所影響。</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="false" variableLength="true" globbing="false" pipelineInput="false" position="named">
<maml:name>Category</maml:name>
<maml:description>
<maml:para>顯示指定類別中的項目相關說明。有效值為 Alias、Cmdlet、Provider 和 HelpFile。概念性主題屬於 HelpFile 類別。
Category 是 Get-Help 傳回之 MamlCommandHelpInfo 物件的屬性。此參數不會影響概念性 ("about_") 說明所顯示的內容。</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>Component</maml:name>
<maml:description>
<maml:para>顯示具有指定之元件值 (如 "Exchange") 的工具清單。請輸入元件名稱。允許使用萬用字元。
Component 是 Get-Help 傳回之 MamlCommandHelpInfo 物件的屬性。此參數不會影響概念 ("About_") 說明所顯示的內容。</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>Detailed</maml:name>
<maml:description>
<maml:para>將參數描述和範例新增至基本說明顯示。
此參數不會影響概念 ("About_") 說明所顯示的內容。</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>Examples</maml:name>
<maml:description>
<maml:para>只顯示名稱、概要和範例。若只要顯示範例,請輸入 "(get-help <Cmdlet 名稱>).examples"。
此參數不會影響概念 ("About_") 說明所顯示的內容。</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>Full</maml:name>
<maml:description>
<maml:para>顯示 Cmdlet 的整個說明檔案,包含參數說明和屬性、範例、輸入和輸出物件類型,以及其他附註。
此參數不會影響概念 ("About_") 說明所顯示的內容。</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>Functionality</maml:name>
<maml:description>
<maml:para>顯示具有指定之功能的項目說明。請輸入功能。允許使用萬用字元。
Functionality 是 Get-Help 傳回之 MamlCommandHelpInfo 物件的屬性。此參數不會影響概念 ("About_") 說明所顯示的內容。</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="true (ByPropertyName)" position="1">
<maml:name>Name</maml:name>
<maml:description>
<maml:para>要求指定之工具或概念性主題的相關說明。請輸入 Cmdlet、提供者、指令碼或函數名稱,例如 Get-Member、概念性主題名稱 (如 "about_Objects") 或別名 (如 "ls")。雖然您可以在 Cmdlet 和提供者名稱中使用萬用字元,但是無法使用萬用字元來尋找函數說明及指令碼說明主題的名稱。
若要為不在 Path 環境變數所列之路徑的指令碼取得說明,請輸入該指令碼的路徑和檔案名稱。
如果您輸入說明主題的確切名稱,則 Get-Help 會顯示該主題的內容。如果您輸入出現於數個說明主題的某一文字或文字模式,則 Get-Help 會列出所有符合的標題。如果您輸入不符合任一說明主題標題的文字,則 Get-Help 會列出其中內容包含該特定文字的主題。
概念性主題 (例如 about_Objects) 的名稱必須以英文輸入,甚至是非英文版的 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="false" globbing="false" pipelineInput="false" position="named">
<maml:name>Online</maml:name>
<maml:description>
<maml:para>以預設的網際網路瀏覽器顯示說明主題的線上版本。此參數只適用於 Cmdlet、函數和指令碼說明主題。
Get-Help 會使用出現在 Cmdlet、函數或指令碼說明主題的<相關連結>一節之第一個項目中的網際網路位址 (統一資源識別項 [URI])。此參數只有當說明主題包含開頭為 "Http" 或 "Https" 的 URI,而且系統上已安裝網際網路瀏覽器時才有效。
如需在您所撰寫之說明主題中支援此功能的詳細資訊,請參閱 about_Comment_Based_Help,並參閱 MSDN (Microsoft Developer Network) Library 中的<如何撰寫 Cmdlet 說明>(英文),網址為 http://go.microsoft.com/fwlink/?LinkID=123415。</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>Parameter</maml:name>
<maml:description>
<maml:para>只顯示指定之參數的詳細描述。允許使用萬用字元。
此參數不會影響概念 ("About_") 說明所顯示的內容。</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>Path</maml:name>
<maml:description>
<maml:para>取得說明 Cmdlet 如何在指定之提供者路徑中運作的說明。請輸入 Windows PowerShell 提供者路徑。
此參數會取得 Cmdlet 說明主題的自訂版本,說明 Cmdlet 在指定之 Windows PowerShell 提供者路徑中的運作方式。此參數只對提供者 Cmdlet 的說明有效,並且只有當提供者包含提供者 Cmdlet 說明主題的自訂版本時才會生效。
若要查看某個提供者路徑的自訂 Cmdlet 說明,請移至該提供者路徑後再輸入 Get-Help 命令,或是從任一路徑位置使用 Get-Help 的 Path 參數指定提供者路徑。如需詳細資訊,請參閱 about_Providers。</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>Role</maml:name>
<maml:description>
<maml:para>顯示指定的使用者角色的自訂化說明。請輸入角色。允許使用萬用字元。
請輸入使用者在組織中扮演的角色。某些 cmdlet 會依據此參數的值,在其說明檔中顯示不同的文字。核心 cmdlet 的說明內容不會受到此參數所影響。</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>無</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.String 或 MamlCommandHelpInfo</maml:name>
<maml:uri />
<maml:description />
</dev:type>
<maml:description>
<maml:para>
<!-- description -->
如果您要求概念性主題,Get-Help 會以字串形式傳回此主題。如果您指定 Cmdlet、函數或指令碼的名稱,它會傳回 MamlCommandHelpInfo 物件。否則,Get-Help 就會傳回 $pshome 目錄中 Help.Format.ps1xml 檔案所指定的其中一個格式化檢視。
</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-Help" 就會顯示 Windows PowerShell 說明系統的相關資訊。
說明的完整檢視 (-full) 包括了內含參數相關資訊的資料表。這張資料表包含下列欄位:
-- Required:必要,指出此為必要 (true) 或選擇性 (false) 參數。
-- Position:位置,指出此為具名或位置 (有編號的) 參數。位置參數必須出現在命令中的指定位置。
-- "Named" 指出參數名稱屬於必要,但是參數可以出現在命令中的任何位置。
-- <Number> 指出參數名稱屬於選擇性,但是當省略此名稱時,參數就必須放在編號所指定的位置。例如,"2" 指出在省略參數名稱時,參數必須是命令中的第二個 (2) 參數或僅當作未命名的參數。如果有使用參數名稱,參數就可以出現在命令中的任何位置。
-- Default value:預設值,指 Windows PowerShell 在您未於命令中包括參數時所使用的參數值。
-- Accepts pipeline input:接受管線輸入,指出您可以 (true) 或不可以 (false) 透過管線將物件傳送到參數。"By Property Name" 表示此管線物件必須具有與該參數名稱相同名稱的屬性。
-- Accepts wildcard characters:接受萬用字元,指出參數的值是否可以包含萬用字元,例如,* 和 ?。
</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-help </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個命令會顯示 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>
-------------------------- 範例 2 --------------------------
</maml:title>
<maml:introduction>
<maml:para>C:\PS></maml:para>
</maml:introduction>
<dev:code>
get-help * </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個命令會顯示在 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>
get-help get-alias
C:\PS>help get-alias
C:\PS>get-alias -? </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這些命令會顯示 get-alias Cmdlet 的基本資訊。"Get-Help" 和 "-?" 命令會將資訊顯示在單一頁面中。"Help" 命令會一次顯示一頁資訊。</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-help about_* </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個命令會顯示包括在 Windows PowerShell 說明中之概念主題的清單。這些主題的開頭都會是 "about_" 字元。若要顯示特定的說明檔案,請輸入 "get-help <主題名稱>",例如 "get-help about_signing"。</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>
get-help ls -detailed </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個命令會指定 Get-ChildItem Cmdlet 的其中一個別名 ("ls"),藉以顯示其詳細說明。Detailed 參數會要求此說明檔案的詳細檢視,其中會包含參數描述和範例。若要查看 Cmdlet 的完整說明檔案,請使用 Full 參數。</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>
get-help format-string -full </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個命令會顯示 Format-String 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>
-------------------------- 範例 7 --------------------------
</maml:title>
<maml:introduction>
<maml:para>C:\PS></maml:para>
</maml:introduction>
<dev:code>
get-help start-service -examples </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個命令會顯示在 Windows PowerShell 命令中使用 start-service 的範例。</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>
-------------------------- 範例 8 --------------------------
</maml:title>
<maml:introduction>
<maml:para>C:\PS></maml:para>
</maml:introduction>
<dev:code>
get-help get-childitem -parameter f* </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個命令會顯示開頭為 "f" 之 Get-ChildItem Cmdlet 參數 (filter 和 force) 的描述。如需所有參數的描述,請輸入 "get-help get-childitem parameter*"。</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>
-------------------------- 範例 9 --------------------------
</maml:title>
<maml:introduction>
<maml:para>C:\PS></maml:para>
</maml:introduction>
<dev:code>
(get-help write-output).syntax </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個命令只會顯示 Write-Output Cmdlet 的語法。
語法是說明物件的多種屬性其中之一;其他屬性還包括描述、詳細資料、範例和參數。若要找出說明物件的所有屬性和方法,請輸入 "get-help <Cmdlet 名稱> | get-member",例如 "get-help start-service | get member"。</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>
-------------------------- 範例 10 --------------------------
</maml:title>
<maml:introduction>
<maml:para>C:\PS></maml:para>
</maml:introduction>
<dev:code>
(get-help trace-command).alertset </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個命令只會顯示 Cmdlet 的附註。這些附註是儲存在說明物件的 alertSet 屬性中。
附註包含概念資訊和 Cmdlet 的使用提示。根據預設,只有在使用 Get-Help 的 Full 參數時才會顯示附註,但是也可以透過使用 alertSet 屬性顯示附註。</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>
-------------------------- 範例 11 --------------------------
</maml:title>
<maml:introduction>
<maml:para>C:\PS></maml:para>
</maml:introduction>
<dev:code>
get-help add-member -full | out-string -stream | select-string -pattern clixml </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>在這個範例中,會示範如何搜尋特定 Cmdlet 說明主題中的文字。這個命令會在 Add-Member Cmdlet 的完整說明主題版本中搜尋 "clixml" 一字。
因為 Get-Help Cmdlet 會產生 MamlCommandHelpInfo 物件而不是字串,所以您需要使用可將說明主題內容轉換為字串的命令,例如 Out-String 或 Out-File。</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>
-------------------------- 範例 12 --------------------------
</maml:title>
<maml:introduction>
<maml:para>C:\PS></maml:para>
</maml:introduction>
<dev:code>
get-help get-member -online </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個命令會顯示 Get-Member 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>
-------------------------- 範例 13 --------------------------
</maml:title>
<maml:introduction>
<maml:para>C:\PS></maml:para>
</maml:introduction>
<dev:code>
get-help remoting </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個命令會顯示其內容包含 "remoting" 一字的主題清單。
如果您輸入的文字未出現在任一說明主題標題中,則 Get-Help 會列出包含該特定文字的主題。</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>
-------------------------- 範例 14 --------------------------
</maml:title>
<maml:introduction>
<maml:para>C:\PS></maml:para>
</maml:introduction>
<dev:code>
get-help get-item -path SQLSERVER:\DataCollection
NAME
Get-Item
SYNOPSIS
Gets a collection of Server objects for the local computer and any computers to which you have made a SQL Server PowerShell connection.
...
C:\PS> cd SQLSERVER:\DataCollection
C:\PS> SQLSERVER:\DataCollection> get-help get-item
NAME
Get-Item
SYNOPSIS
Gets a collection of Server objects for the local computer and any computers to which you have made a SQL Server PowerShell connection.
...
C:\PS> Get-Item
NAME
Get-Item
SYNOPSIS
Gets the item at the specified location.
... </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>在這個範例中,會示範如何取得 Get-Item Cmdlet 的說明,以描述如何在 Windows PowerShell SQL Server 提供者的 DataCollection 節點中使用 Cmdlet。
此範例示範兩種取得 Get-Item 自訂說明的方式。
第一個命令會使用 Get-Help 的 Path 參數指定提供者路徑。這個命令可於任何路徑位置輸入。
第二個命令會使用 Set-Location Cmdlet (別名為 "cd") 移至提供者路徑。即使不指定 Path 參數,Get-Help 命令從該位置也能取得提供者路徑的自訂說明。
第三個命令示範檔案系統路徑中的 Get-Help 命令 (不指定 Path 路徑) 取得 Get-Item 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>
-------------------------- 範例 15 --------------------------
</maml:title>
<maml:introduction>
<maml:para>C:\PS></maml:para>
</maml:introduction>
<dev:code>
get-help c:\ps-test\MyScript.ps1 </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個命令會取得 MyScript.ps1 指令碼的說明。如需針對函數和指令碼撰寫說明的詳細資訊,請參閱 about_Comment_Based_Help。</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=113316</maml:uri>
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText></maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>about_Comment_Based_Help</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Get-Command</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Get-PSDrive</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Get-Member</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-History
</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>History</command:noun>
<dev:version></dev:version>
</command:details>
<maml:description>
<maml:para>Get-History Cmdlet 會取得工作階段歷程記錄,也就是在目前工作階段期間所輸入命令的清單。Windows PowerShell 會自動維護每個工作階段的歷程記錄。您可以將工作階段歷程記錄儲存成 XML 或 CSV 格式。預設情況下,歷程記錄檔案會儲存在主目錄中,不過,您可以將此檔案儲存到任何位置。</maml:para>
</maml:description>
<!-- Cmdlet syntax section-->
<command:syntax>
<command:syntaxItem>
<maml:name>Get-History</maml:name>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="true (ByValue)" position="1">
<maml:name>Id</maml:name>
<maml:description>
<maml:para>指定命令在工作階段歷程記錄中的識別碼。Get-History 只會取得指定的命令。如果同時指定 Id 和 Count,Get-History 便會取得結尾為 Id 參數所指定之最近的命令。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="true">Int64[]</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="2">
<maml:name>Count</maml:name>
<maml:description>
<maml:para>顯示指定個數的最近歷程記錄項目。預設值為 32。如果您同時在命令中使用 Count 和 Id 參數,顯示清單將以 Id 參數所指定的命令結尾。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">int</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>Count</maml:name>
<maml:description>
<maml:para>顯示指定個數的最近歷程記錄項目。預設值為 32。如果您同時在命令中使用 Count 和 Id 參數,顯示清單將以 Id 參數所指定的命令結尾。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">int</command:parameterValue>
<dev:type>
<maml:name>int</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue></dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="true (ByValue)" position="1">
<maml:name>Id</maml:name>
<maml:description>
<maml:para>指定命令在工作階段歷程記錄中的識別碼。Get-History 只會取得指定的命令。如果同時指定 Id 和 Count,Get-History 便會取得結尾為 Id 參數所指定之最近的命令。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="true">Int64[]</command:parameterValue>
<dev:type>
<maml:name>Int64[]</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>Int64</maml:name>
<maml:uri />
<maml:description />
</dev:type>
<maml:description>
<maml:para>
<!-- description -->
您可以經由管道將歷程記錄識別碼輸出至 Get-History。
</maml:para>
</maml:description>
</command:inputType>
</command:inputTypes>
<command:returnValues>
<command:returnValue>
<dev:type>
<maml:name>Microsoft.PowerShell.Commands.HistoryInfo</maml:name>
<maml:uri />
<maml:description />
</dev:type>
<maml:description>
<maml:para>
<!-- description -->
Get-History 會針對它所取得的每個歷程記錄項目傳回一個歷程記錄物件。
</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 便會將其新增至歷程記錄,讓您可以重複使用。如需命令歷程記錄的詳細資訊,請參閱 about_History。
您也可以利用內建的別名 "h"、"history" 和 "ghy" 來參照 Get-History。如需詳細資訊,請參閱 about_Aliases。
</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-history </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個命令會取得 32 個最近提交的命令。預設顯示會列出每個命令,以及可指出其執行順序的識別碼。</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-history | where-object {$_.commandLine -like "*service*"} </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個命令會從命令歷程記錄中取得包含 "service" 一字的項目。第一個命令會取得工作階段歷程記錄中 32 個最近的項目。管線運算子 (|) 會將結果傳遞到 Where-Object Cmdlet,並由後者僅選取包含 "service" 的命令。</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-history -id 7 -count 5 | export-csv history.csv </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個命令會取得最後一個項目識別碼為 7 的五個最近的歷程記錄項目。管線運算子 (|) 會將結果傳遞到 Export-Csv Cmdlet,此 Cmdlet 會將歷程記錄格式化為以逗號分隔的文字,同時儲存到 History.csv 檔案。此檔案包含了歷程記錄格式化成為清單時所顯示的資料,其中包括命令的狀態、開始時間和結束時間。</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-history -count 1 </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個命令會取得命令歷程記錄中的最後一個 (最近輸入的) 命令。它會使用 Count 參數以便僅顯示一個命令。根據預設,Get-History 會顯示最近的命令。這個命令可以縮寫成 "h -c 1",而且與按向上鍵具有相同作用。</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>
get-history -count $MaximumHistoryCount </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個命令會顯示儲存在工作階段歷程記錄中的所有命令。預設情況下,$MaximumHistoryCount 是 64,因此這個命令可以縮寫成 "h -c 64"。</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>
get-history | format-list </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個命令會顯示工作階段歷程記錄中項目的所有屬性。管線運算子 (|) 會將結果傳遞至 Format-List Cmdlet,此 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:examples>
<!-- Link section -->
<maml:relatedLinks>
<maml:navigationLink>
<maml:linkText>Online version:</maml:linkText>
<maml:uri>http://go.microsoft.com/fwlink/?LinkID=113317</maml:uri>
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>about_history</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Invoke-History</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Add-History</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Clear-History</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-Job
</command:name>
<maml:description>
<maml:para>取得目前工作階段中執行的 Windows PowerShell 背景工作。</maml:para>
</maml:description>
<maml:copyright>
<maml:para></maml:para>
</maml:copyright>
<command:verb>Get</command:verb>
<command:noun>Job</command:noun>
<dev:version></dev:version>
</command:details>
<maml:description>
<maml:para>Get-Job Cmdlet 會取得表示在目前工作階段中啟動之背景工作的物件。您可以使用 Get-Job 取得透過 Start-Job 或透過任何 Cmdlet 的 AsJob 參數所啟動的工作。
如果未指定參數,"Get-Job" 命令會取得目前工作階段中的所有工作。您可以使用 Get-Job 的各項參數取得特定工作。
Get-Job 傳回的工作物件包含有用的工作資訊,但不包含工作結果。若要取得工作結果,請使用 Receive-Job Cmdlet。
Windows PowerShell 背景工作是「在背景中」執行、與目前工作階段沒有互動的命令。通常您會使用背景工作來執行需要長時間完成的複雜命令。如需 Windows PowerShell 中背景工作的詳細資訊,請參閱 about_Jobs。</maml:para>
</maml:description>
<!-- Cmdlet syntax section-->
<command:syntax>
<command:syntaxItem>
<maml:name>Get-Job</maml:name>
<command:parameter required="false" variableLength="true" globbing="true" pipelineInput="true (ByPropertyName)" position="named">
<maml:name>Command</maml:name>
<maml:description>
<maml:para>取得包含指定之命令的工作。預設為所有工作。請以字串形式輸入命令。您可以使用萬用字元指定命令模式。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="true">string[]</command:parameterValue>
</command:parameter>
</command:syntaxItem>
<command:syntaxItem>
<maml:name>Get-Job</maml:name>
<command:parameter required="false" variableLength="true" globbing="true" pipelineInput="true (ByPropertyName)" position="1">
<maml:name>InstanceId</maml:name>
<maml:description>
<maml:para>取得具有指定之執行個體識別碼的工作。預設為所有工作。
執行個體識別碼是一種 GUID,它能夠唯一識別電腦上的工作。若要尋找工作的執行個體識別碼,請使用 Get-Job。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="true">Guid[]</command:parameterValue>
</command:parameter>
</command:syntaxItem>
<command:syntaxItem>
<maml:name>Get-Job</maml:name>
<command:parameter required="false" variableLength="true" globbing="true" pipelineInput="true (ByPropertyName)" position="1">
<maml:name>Name</maml:name>
<maml:description>
<maml:para>取得具有指定之好記名稱的工作。請輸入工作名稱,或是使用萬用字元輸入工作名稱模式。根據預設,Get-Job 會取得目前工作階段中的所有工作。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="true">string[]</command:parameterValue>
</command:parameter>
</command:syntaxItem>
<command:syntaxItem>
<maml:name>Get-Job</maml:name>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="true (ByPropertyName)" position="1">
<maml:name>Id</maml:name>
<maml:description>
<maml:para>只取得具有指定之識別碼的工作。
識別碼是整數,可唯一識別目前工作階段內的工作。雖然它比執行個體識別碼更容易記得和輸入,但是只有在目前的工作階段中才具有唯一性。您可以輸入一個或多個識別碼 (以逗號分隔)。若要尋找工作的識別碼,請輸入 "Get-Job" 且不要指定參數。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="true">Int32[]</command:parameterValue>
</command:parameter>
</command:syntaxItem>
<command:syntaxItem>
<maml:name>Get-Job</maml:name>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="true (ByPropertyName)" position="named">
<maml:name>State</maml:name>
<maml:description>
<maml:para>只取得具有指定之狀態的工作。有效的值包括 NotStarted、Running、Completed、Stopped、Failed 和 Blocked。根據預設,Get-Job 會取得目前工作階段中的所有工作。</maml:para>
</maml:description>
<command:parameterValueGroup>
<command:parameterValue required="false" variableLength="false">NotStarted</command:parameterValue>
<command:parameterValue required="false" variableLength="false">Running</command:parameterValue>
<command:parameterValue required="false" variableLength="false">Completed</command:parameterValue>
<command:parameterValue required="false" variableLength="false">Failed</command:parameterValue>
<command:parameterValue required="false" variableLength="false">Stopped</command:parameterValue>
<command:parameterValue required="false" variableLength="false">Blocked</command:parameterValue>
</command:parameterValueGroup>
</command:parameter>
</command:syntaxItem>
</command:syntax>
<!-- Cmdlet parameter section -->
<command:parameters>
<command:parameter required="false" variableLength="true" globbing="true" pipelineInput="true (ByPropertyName)" position="named">
<maml:name>Command</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="true" globbing="false" pipelineInput="true (ByPropertyName)" position="1">
<maml:name>Id</maml:name>
<maml:description>
<maml:para>只取得具有指定之識別碼的工作。
識別碼是整數,可唯一識別目前工作階段內的工作。雖然它比執行個體識別碼更容易記得和輸入,但是只有在目前的工作階段中才具有唯一性。您可以輸入一個或多個識別碼 (以逗號分隔)。若要尋找工作的識別碼,請輸入 "Get-Job" 且不要指定參數。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="true">Int32[]</command:parameterValue>
<dev:type>
<maml:name>Int32[]</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue></dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="true" pipelineInput="true (ByPropertyName)" position="1">
<maml:name>InstanceId</maml:name>
<maml:description>
<maml:para>取得具有指定之執行個體識別碼的工作。預設為所有工作。
執行個體識別碼是一種 GUID,它能夠唯一識別電腦上的工作。若要尋找工作的執行個體識別碼,請使用 Get-Job。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="true">Guid[]</command:parameterValue>
<dev:type>
<maml:name>Guid[]</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue></dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="true" pipelineInput="true (ByPropertyName)" position="1">
<maml:name>Name</maml:name>
<maml:description>
<maml:para>取得具有指定之好記名稱的工作。請輸入工作名稱,或是使用萬用字元輸入工作名稱模式。根據預設,Get-Job 會取得目前工作階段中的所有工作。</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="true (ByPropertyName)" position="named">
<maml:name>State</maml:name>
<maml:description>
<maml:para>只取得具有指定之狀態的工作。有效的值包括 NotStarted、Running、Completed、Stopped、Failed 和 Blocked。根據預設,Get-Job 會取得目前工作階段中的所有工作。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">JobState</command:parameterValue>
<dev:type>
<maml:name>JobState</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.RemotingJob</maml:name>
<maml:uri />
<maml:description />
</dev:type>
<maml:description>
<maml:para>
<!-- description -->
Get-Job 會傳回代表工作階段中各項工作的物件。
</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>
get-job </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>
$j = get-job -name Job1
C:\PS> $ID = $j.InstanceID
C:\PS> $ID
Guid
----
03c3232e-1d23-453b-a6f4-ed73c9e29d55
C:\PS> stop-job -instanceid $ID </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這些命令示範如何取得工作的執行個體識別碼,然後使用它來停止工作。不像工作名稱不具唯一性,執行個體識別碼是唯一的。
第一個命令會使用 Get-Job Cmdlet 取得工作。它會使用 Name 參數識別工作,並將 Get-Job 所傳回的工作物件儲存在 $j 變數中。在這個範例中,只有一個工作具有指定的名稱。
第二個命令會取得 $j 變數中物件的 InstanceId 屬性,並將它儲存在 $ID 變數中。
第三個命令會顯示 $ID 變數的值。
第四個命令會使用 Stop-Job Cmdlet 停止工作。它會使用 InstanceId 參數識別工作,並使用 $ID 變數表示工作的執行個體識別碼。</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-job -command "*get-process*" </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個命令會取得系統上包含 Get-Process 命令的工作,命令中會使用 Get-Job 的 Command 參數限制所擷取的工作。命令中使用的萬用字元 (*) 是用來取得命令字串中的任何位置包含 Get-Process 命令的工作。</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-process*" | get-job </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>如同上一個範例中的命令,這個命令會取得系統上包含 Get-Process 命令的工作。這個命令會使用管線運算子 (|) 將字串 (用雙引號括住) 傳送至 Get-Job 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>
get-job -state NotStarted </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>
-------------------------- 範例 6 --------------------------
</maml:title>
<maml:introduction>
<maml:para>C:\PS></maml:para>
</maml:introduction>
<dev:code>
get-job -name job* </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個命令會取得工作名稱開頭為 "job" 的所有工作。因為 "job<number>" 是工作的預設名稱,所以這個命令會取得沒有明確指定名稱的所有工作。</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>
-------------------------- 範例 7 --------------------------
</maml:title>
<maml:introduction>
<maml:para>C:\PS></maml:para>
</maml:introduction>
<dev:code>
start-job -scriptblock {get-process} -name MyJob
C:\PS> $j = get-job -name MyJob
C:\PS> $j
Id Name State HasMoreData Location Command
-- ---- ----- ----------- -------- -------
1 myjob Completed True localhost get-process
C:\PS> receive-job -job $j
Handles NPM(K) PM(K) WS(K) VM(M) CPU(s) Id ProcessName
------- ------ ----- ----- ----- ------ -- -----------
124 4 13572 12080 59 1140 audiodg
783 16 11428 13636 100 548 CcmExec
96 4 4252 3764 59 3856 ccmsetup
... </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個範例會示範如何使用 Get-Job 取得工作物件,然後使用該物件名稱表示命令中的工作。
第一個命令會使用 Start-Job Cmdlet 啟動一個在本機電腦上執行 Get-Process 命令的背景工作。這個命令會使用 Start-Job 的 Name 參數,將好記的名稱指定給工作。
第二個命令會使用 Get-Job 取得此工作。它會使用 Get-Job 的 Name 參數識別工作,並將產生的工作物件儲存在 $j 變數中。
第三個命令會顯示 $j 變數中工作物件的值。State 屬性的值顯示此工作已完成。HasMoreData 屬性的值顯示工作有未擷取的結果。
第四個命令會使用 Receive-Job Cmdlet 取得工作結果。它會使用 $j 變數中的工作物件來表示此工作。您也可以使用管線運算子將工作物件傳送至 Receive-Job。</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>
-------------------------- 範例 8 --------------------------
</maml:title>
<maml:introduction>
<maml:para>C:\PS></maml:para>
</maml:introduction>
<dev:code>
start-job -scriptblock {get-eventlog system}
C:\PS> invoke-command -computername S1 -scriptblock {get-eventlog system} -AsJob
C:\PS> invoke-command -computername S2 -scriptblock {start-job -scriptblock {get-eventlog system}}
C:\PS> get-job
Id Name State HasMoreData Location Command
-- ---- ----- ----------- -------- -------
1 Job1 Running True localhost get-eventlog system
2 Job2 Running True S1 get-eventlog system
C:\PS> invoke-command -computername S2 -scriptblock {get-job}
Id Name State HasMoreData Location Command
-- ---- ----- ----------- -------- -------
4 Job4 Running True localhost get-eventlog system
</dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>在這個範例中,會示範 Get-Job Cmdlet 可以取得在目前工作階段中啟動的所有工作,即使該工作是透過不同方法啟動也一樣。
第一個命令會使用 Start-Job Cmdlet,在本機電腦啟動工作。
第二個命令會使用 Invoke-Command 的 AsJob 參數,在 S1 電腦啟動工作。即使此工作中的命令是在遠端電腦執行,但仍會在本機電腦建立工作物件,因此您可以使用本機命令管理工作。
第三個命令會使用 Invoke-Command Cmdlet,在 S2 電腦執行 Start-Job 命令。透過這個方式,即可在遠端電腦建立工作物件,讓您可以使用遠端命令管理工作。
第四個命令會使用 Get-Job 取得儲存在本機電腦的工作。
第五個命令會使用 Invoke-Command,在 S2 電腦執行 Get-Job 命令。
範例輸出會顯示 Get-Job 命令的結果。
如需在遠端電腦上執行背景工作的詳細資訊,請參閱 about_Remote_Jobs。</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>
-------------------------- 範例 9 --------------------------
</maml:title>
<maml:introduction>
<maml:para>C:\PS></maml:para>
</maml:introduction>
<dev:code>
start-job -scriptblock {get-process}
Id Name State HasMoreData Location Command
-- ---- ----- ----------- -------- -------
1 Job1 Failed False localhost get-process
C:\PS> (get-job).jobstateinfo | format-list -property *
State : Failed
Reason :
C:\PS> get-job | format-list *
HasMoreData : False
StatusMessage :
Location : localhost
Command : get-process
JobStateInfo : Failed
Finished : System.Threading.ManualResetEvent
InstanceId : fb792295-1318-4f5d-8ac8-8a89c5261507
Id : 1
Name : Job1
ChildJobs : {Job2}
Output : {}
Error : {}
Progress : {}
Verbose : {}
Debug : {}
Warning : {}
StateChanged :
C:\PS> (get-job -name job2).jobstateinfo.reason
Connecting to remote server using WSManCreateShellEx api failed. The async callback gave the following error message :
Access is denied. </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>在這個範例中,會示範如何使用 Get-Job 傳回的工作物件,調查工作失敗原因。此外,也會示範如何取得每個工作的子工作。
第一個命令會使用 Start-Job Cmdlet,在本機電腦啟動工作。Start-Job 傳回的工作物件顯示該工作失敗。State 屬性值為 "Failed"。
第二個命令會使用 Get-Job 取得工作物件。這個命令會使用點標記法,取得物件的 JobStateInfo 屬性值。它會使用管線運算子將 JobStateInfo 屬性中的物件傳送至 Format-List Cmdlet,此 Cmdlet 會以清單格式列出此物件的所有屬性 (*)。
Format-List 命令的結果顯示此工作的 Reason 屬性值為空白。
第三個命令會進一步調查。它會使用 Get-Job 命令取得此工作,然後使用管線運算子將整個工作物件傳送至 Format-List Cmdlet,此 Cmdlet 會將此工作的所有屬性顯示在清單中。
此工作物件中顯示的所有屬性可知此工作包含名為 "Job2" 的子工作。
第四個命令會使用 Get-Job 取得表示 Job2 子工作的工作物件。這是此命令實際執行所在的工作。這個命令會使用點標記法,取得 JobStateInfo 屬性的 Reason 屬性。
結果顯示工作因為「拒絕存取」錯誤而失敗。這是因為在此例中,使用者在開啟 Windows PowerShell 時忘記使用 [以系統管理員身分執行] 選項所導致。
因為背景工作會使用 Windows PowerShell 的遠端功能,所以即使是在本機電腦執行工作,此電腦也必須設定為可供遠端執行工作。
如需 Windows PowerShell 遠端功能需求的詳細資訊,請參閱 about_Remote_Requirements。如需疑難排解提示,請參閱 about_Remote_Troubleshooting。</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=113328</maml:uri>
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>about_Jobs</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>about_Job_details</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>about_Remote_Jobs</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Start-Job</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Receive-Job</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Wait-Job</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Stop-Job</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Remove-Job</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Invoke-Command</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-Module
</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>Module</command:noun>
<dev:version></dev:version>
</command:details>
<maml:description>
<maml:para>Get-Module Cmdlet 會取得已匯入或可匯入至此工作階段的模組。
Get-Module 只會取得模組,但無法匯入模組。若要將模組匯入至工作階段,請使用 Import-Module。</maml:para>
</maml:description>
<!-- Cmdlet syntax section-->
<command:syntax>
<command:syntaxItem>
<maml:name>Get-Module</maml:name>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>All</maml:name>
<maml:description>
<maml:para>取得所有模組檔案的模組物件。
如果沒有使用 All 參數,Get-Module 只會取得預設模組檔案的模組物件。此 Cmdlet 會依照下列順序選取檔案類型:資訊清單 (.psd1) 檔案、指令碼模組 (.psm1) 檔案和二進位模組 (.dll) 檔案。</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>ListAvailable</maml:name>
<maml:description>
<maml:para>取得所有可匯入至此工作階段的模組。Get-Module 會取得 $env:PSModulePath 環境變數所指定之路徑中的模組。
如果未指定這個參數,Get-Module 只會取得已匯入至此工作階段的模組。</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="true" pipelineInput="false" position="named">
<maml:name>Name</maml:name>
<maml:description>
<maml:para>只取得具有指定之名稱或名稱模式的模組。允許使用萬用字元。您也可以經由管道將名稱輸出至 Get-Module。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="true">string[]</command:parameterValue>
</command:parameter>
</command:syntaxItem>
<command:syntaxItem>
<maml:name>Get-Module</maml:name>
<command:parameter required="false" variableLength="true" globbing="true" pipelineInput="true (ByValue)" position="1">
<maml:name>Name</maml:name>
<maml:description>
<maml:para>只取得具有指定之名稱或名稱模式的模組。允許使用萬用字元。您也可以經由管道將名稱輸出至 Get-Module。</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="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>All</maml:name>
<maml:description>
<maml:para>取得所有模組檔案的模組物件。
如果沒有使用 All 參數,Get-Module 只會取得預設模組檔案的模組物件。此 Cmdlet 會依照下列順序選取檔案類型:資訊清單 (.psd1) 檔案、指令碼模組 (.psm1) 檔案和二進位模組 (.dll) 檔案。</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>ListAvailable</maml:name>
<maml:description>
<maml:para>取得所有可匯入至此工作階段的模組。Get-Module 會取得 $env:PSModulePath 環境變數所指定之路徑中的模組。
如果未指定這個參數,Get-Module 只會取得已匯入至此工作階段的模組。</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="true" pipelineInput="true (ByValue)" position="1">
<maml:name>Name</maml:name>
<maml:description>
<maml:para>只取得具有指定之名稱或名稱模式的模組。允許使用萬用字元。您也可以經由管道將名稱輸出至 Get-Module。</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-Module。
</maml:para>
</maml:description>
</command:inputType>
</command:inputTypes>
<command:returnValues>
<command:returnValue>
<dev:type>
<maml:name>System.Management.Automation.PSModuleInfo</maml:name>
<maml:uri />
<maml:description />
</dev:type>
<maml:description>
<maml:para>
<!-- description -->
Get-Module 會傳回代表模組的物件。
</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-Module 的別名 ("gmo") 來表示此 Cmdlet。如需詳細資訊,請參閱 about_Aliases。
All 參數會傳回副檔名為 .dll 之所有檔案的模組物件,即使這些檔案沒有實作 Cmdlet 或提供者也一樣。
</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-module </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>
get-module -listAvailable </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個命令會取得可匯入至目前工作階段的模組。
Get-Module 會在 $env:PSModulePath 環境變數所指定的路徑中尋找可用的模組。如需 PSModulePath 的詳細資訊,請參閱 about_Modules 和 about_Environment_Variables。</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-module -listAvailable -all </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>
-------------------------- 範例 4 --------------------------
</maml:title>
<maml:introduction>
<maml:para>C:\PS></maml:para>
</maml:introduction>
<dev:code>
get-module | get-member -type property
TypeName: System.Management.Automation.PSModuleInfo
Name MemberType Definition
---- ---------- ----------
AccessMode Property System.Management.Automation.ModuleAcc
Description Property System.String Description {get;set;}
ExportedAliases Property System.Collections.Generic.Dictionary`
ExportedCmdlets Property System.Collections.Generic.Dictionary`
ExportedFunctions Property System.Collections.Generic.Dictionary`
ExportedVariables Property System.Collections.Generic.Dictionary`
Guid Property System.Guid Guid {get;}
ModuleBase Property System.String ModuleBase {get;}
ModuleType Property System.Management.Automation.ModuleTyp
Name Property System.String Name {get;}
NestedModules Property System.Collections.ObjectModel.ReadOnl
OnRemove Property System.Management.Automation.ScriptBlo
Path Property System.String Path {get;}
PrivateData Property System.Object PrivateData {get;set;}
SessionState Property System.Management.Automation.SessionSt
Version Property System.Version Version {get;} </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個命令會取得 Get-Module 傳回之 PSModuleInfo 物件的屬性。每個模組檔案都有一個代表物件。
您可以使用這些屬性,格式化及篩選模組物件。如需這些屬性的詳細資訊,請參閱 MSDN (Microsoft Developer Network) Library 中的<PSModule 屬性>(英文),網址為:http://go.microsoft.com/fwlink/?LinkId=143624。</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>
get-module -listAvailable -all | format-table -property name, moduletype, path -groupby name -auto
Name: MyTestCmdlets
Name ModuleType Path
---- ---------- ----
MyTestCmdlets Script C:\Windows\system32\WindowsPowerShell\v1.0\Modules\TestCmdlets\TestCmdlets.dll
Name: PSDiagnostics
Name ModuleType Path
---- ---------- ----
PSDiagnostics Manifest C:\Windows\system32\WindowsPowerShell\v1.0\Modules\PSDiagnostics\PSDiagnostics.psd1
PSDiagnostics Script C:\Windows\system32\WindowsPowerShell\v1.0\Modules\PSDiagnostics\PSDiagnostics.psm1
Name: FileTransfer
Name ModuleType Path
---- ---------- ----
FileTransfer Manifest C:\Windows\system32\WindowsPowerShell\v1.0\Modules\FileTransfer\FileTransfer.psd1
</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>
-------------------------- 範例 6 --------------------------
</maml:title>
<maml:introduction>
<maml:para>C:\PS></maml:para>
</maml:introduction>
<dev:code>
$m = get-module -list -name FileTransfer | where {$_.moduletype -eq "Manifest"}
C:\PS> get-content $m.path
@{
GUID="{8FA5064B-8479-4c5c-86EA-0D311FE48875}"
Author="Microsoft Corporation"
CompanyName="Microsoft Corporation"
Copyright="© Microsoft Corporation. All rights reserved."
ModuleVersion="1.0.0.0"
Description="Windows Powershell File Transfer Module"
PowerShellVersion="2.0"
CLRVersion="2.0"
NestedModules="Microsoft.BackgroundIntelligentTransfer.Management"
FormatsToProcess="FileTransfer.Format.ps1xml"
RequiredAssemblies=Join-Path $psScriptRoot "Microsoft.BackgroundIntelligentTransfer.Management.Interop.dll"
} </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這些命令會顯示 Windows PowerShell 檔案傳輸模組的模組資訊清單內容。
第一個命令會取得 PSModuleInfo 物件,此物件表示檔案傳輸模組的模組資訊清單。這個命令會將該物件儲存在 $m 變數中。
第二個命令會使用點標記法,取得儲存在物件之 Path 屬性中資訊清單檔案的路徑。然後,再使用 Get-Content 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>
-------------------------- 範例 7 --------------------------
</maml:title>
<maml:introduction>
<maml:para>C:\PS></maml:para>
</maml:introduction>
<dev:code>
get-module -listAvailable -name FileTransfer | format-list -property *
Name : FileTransfer
Path : C:\Windows\system32\WindowsPowerShell\v1.0\Modules\FileTransfer\FileTransfer.psd1
Description : Powershell File Transfer Module
Guid : 8fa5064b-8479-4c5c-86ea-0d311fe48875
ModuleBase : C:\Windows\system32\WindowsPowerShell\v1.0\Modules\FileTransfer
PrivateData :
Version : 1.0.0.0
ModuleType : Manifest
AccessMode : ReadWrite
ExportedFunctions : {}
ExportedCmdlets : {}
NestedModules : {}
ExportedVariables : {}
ExportedAliases : {}
SessionState : System.Management.Automation.SessionState
OnRemove : </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個命令會在清單中顯示 FileTransfer 模組的所有屬性。
因為尚未將此模組匯入至工作階段,所以尚未填入 Exported* 屬性和 NestedModules 屬性。只有在匯出這些元素並已將巢狀模組具現化之後,才會填入這些屬性。</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>
-------------------------- 範例 8 --------------------------
</maml:title>
<maml:introduction>
<maml:para>C:\PS></maml:para>
</maml:introduction>
<dev:code>
dir (get-module -listavailable FileTransfer).modulebase
Directory: C:\Windows\system32\WindowsPowerShell\v1.0\Modules\FileTransfer
Mode LastWriteTime Length Name
---- ------------- ------ ----
d---- 12/16/2008 12:36 PM en-US
-a--- 11/19/2008 11:30 PM 16184 FileTransfer.Format.ps1xml
-a--- 11/20/2008 11:30 PM 1044 FileTransfer.psd1
-a--- 12/16/2008 12:20 AM 108544 Microsoft.BackgroundIntelligentTransfer.Management.Interop.dll </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:examples>
<!-- Link section -->
<maml:relatedLinks>
<maml:navigationLink>
<maml:linkText>Online version:</maml:linkText>
<maml:uri>http://go.microsoft.com/fwlink/?LinkID=141552</maml:uri>
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Import-Module</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>New-Module</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Remove-Module</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>about_Modules</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-PSSession
</command:name>
<maml:description>
<maml:para>取得目前工作階段中的 Windows PowerShell 工作階段 (PSSession)。</maml:para>
</maml:description>
<maml:copyright>
<maml:para></maml:para>
</maml:copyright>
<command:verb>Get</command:verb>
<command:noun>PSSession</command:noun>
<dev:version></dev:version>
</command:details>
<maml:description>
<maml:para>Get-PSSession Cmdlet 會取得在目前工作階段中建立的 Windows PowerShell 工作階段 (PSSession)。
如果沒有使用參數,Get-PSSession 會取得目前工作階段中建立的所有 PSSession。您可以使用 Get-PSSession 的各項參數取得連線至特定電腦的工作階段,也可以依照工作階段的名稱、識別碼或執行個體識別碼識別這些工作階段。
如需 Windows PowerShell 工作階段的詳細資訊,請參閱 about_PSSessions。</maml:para>
</maml:description>
<!-- Cmdlet syntax section-->
<command:syntax>
<command:syntaxItem>
<maml:name>Get-PSSession</maml:name>
<command:parameter required="false" variableLength="true" globbing="true" pipelineInput="true (ByPropertyName)" position="1">
<maml:name>ComputerName</maml:name>
<maml:description>
<maml:para>只取得連線至指定之電腦的 PSSession。允許使用萬用字元。
請輸入一台或多台電腦的 NetBIOS 名稱、IP 位址或完整網域名稱。若要指定本機電腦,請輸入電腦名稱、"localhost" 或點 (.)。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="true">string[]</command:parameterValue>
</command:parameter>
</command:syntaxItem>
<command:syntaxItem>
<maml:name>Get-PSSession</maml:name>
<command:parameter required="true" variableLength="true" globbing="false" pipelineInput="true (ByPropertyName)" position="1">
<maml:name>Id</maml:name>
<maml:description>
<maml:para>只取得具有指定之識別碼的 PSSession。請輸入一個或多個識別碼 (以逗號分隔),或使用範圍運算子 (..) 指定識別碼範圍。
識別碼是整數,可唯一識別目前工作階段中的 PSSession。它比 InstanceId 更容易記得和輸入,但是只有在目前的工作階段中才具有唯一性。若要尋找 PSSession 的識別碼,請輸入 Get-PSSession 且不要指定參數。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="true">Int32[]</command:parameterValue>
</command:parameter>
</command:syntaxItem>
<command:syntaxItem>
<maml:name>Get-PSSession</maml:name>
<command:parameter required="false" variableLength="true" globbing="true" pipelineInput="true (ByPropertyName)" position="named">
<maml:name>InstanceId</maml:name>
<maml:description>
<maml:para>只取得具有指定之執行個體識別碼的 PSSession。
執行個體識別碼是一種 GUID,能夠唯一識別本機或遠端電腦上的 PSSession。InstanceID 具有唯一性,即使 Windows PowerShell 中有多個正在執行的工作階段也一樣。
InstanceID 儲存在代表 PSSession 之物件的 InstanceID 屬性中。若要尋找目前工作階段中 PSSession 的 InstanceID,請輸入 "get-pssession | format-table Name, ComputerName, InstanceId"。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="true">Guid[]</command:parameterValue>
</command:parameter>
</command:syntaxItem>
<command:syntaxItem>
<maml:name>Get-PSSession</maml:name>
<command:parameter required="false" variableLength="true" globbing="true" pipelineInput="true (ByPropertyName)" position="named">
<maml:name>Name</maml:name>
<maml:description>
<maml:para>只取得具有指定之好記名稱的 PSSession。允許使用萬用字元。
若要尋找目前工作階段中 PSSession 的名稱,請輸入不含參數的 "get-pssession"。
</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="false" variableLength="true" globbing="true" pipelineInput="true (ByPropertyName)" position="1">
<maml:name>ComputerName</maml:name>
<maml:description>
<maml:para>只取得連線至指定之電腦的 PSSession。允許使用萬用字元。
請輸入一台或多台電腦的 NetBIOS 名稱、IP 位址或完整網域名稱。若要指定本機電腦,請輸入電腦名稱、"localhost" 或點 (.)。</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="true" variableLength="true" globbing="false" pipelineInput="true (ByPropertyName)" position="1">
<maml:name>Id</maml:name>
<maml:description>
<maml:para>只取得具有指定之識別碼的 PSSession。請輸入一個或多個識別碼 (以逗號分隔),或使用範圍運算子 (..) 指定識別碼範圍。
識別碼是整數,可唯一識別目前工作階段中的 PSSession。它比 InstanceId 更容易記得和輸入,但是只有在目前的工作階段中才具有唯一性。若要尋找 PSSession 的識別碼,請輸入 Get-PSSession 且不要指定參數。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="true">Int32[]</command:parameterValue>
<dev:type>
<maml:name>Int32[]</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>殼層中的所有工作階段</dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="true" pipelineInput="true (ByPropertyName)" position="named">
<maml:name>InstanceId</maml:name>
<maml:description>
<maml:para>只取得具有指定之執行個體識別碼的 PSSession。
執行個體識別碼是一種 GUID,能夠唯一識別本機或遠端電腦上的 PSSession。InstanceID 具有唯一性,即使 Windows PowerShell 中有多個正在執行的工作階段也一樣。
InstanceID 儲存在代表 PSSession 之物件的 InstanceID 屬性中。若要尋找目前工作階段中 PSSession 的 InstanceID,請輸入 "get-pssession | format-table Name, ComputerName, InstanceId"。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="true">Guid[]</command:parameterValue>
<dev:type>
<maml:name>Guid[]</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue></dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="true" pipelineInput="true (ByPropertyName)" position="named">
<maml:name>Name</maml:name>
<maml:description>
<maml:para>只取得具有指定之好記名稱的 PSSession。允許使用萬用字元。
若要尋找目前工作階段中 PSSession 的名稱,請輸入不含參數的 "get-pssession"。
</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>無</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.Runspaces.PSSession</maml:name>
<maml:uri />
<maml:description />
</dev:type>
<maml:description>
<maml:para>
<!-- description -->
Get-PSSession 會針對它所取得的每個 PSSession 傳回一個 PSSession 物件。
</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-PSSession 會取得在目前工作階段中建立的 PSSession。它不會取得開啟 Windows PowerShell 時所建立的工作階段,也不會取得在其他工作階段中或在其他電腦所建立的 PSSession,即使這些 PSSession 連線至本機電腦也一樣。
</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-pssession </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個命令會取得在目前工作階段中建立的所有 PSSession。
它不會取得在其他工作階段中或在其他電腦所建立的 PSSession,即使這些 PSSession 連線至此電腦也一樣。</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>
$s = get-pssession -computername Server02 </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個命令會取得連線至 Server02 電腦的 PSSession,並將其儲存在 $p 變數中。</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>
new-pssession -computername Server01, Server02, Server03
C:\PS> $s1, $s2, $s3 = get-pssession </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>在這個範例中,會示範如何將 Get-PSSession 命令的結果儲存在多個變數中。
第一個命令會使用 New-PSSession Cmdlet,在三個遠端電腦建立 PSSession。
第二個命令會使用 Get-PSSession Cmdlet 取得這三個 PSSession。然後,再將每個 PSSession 儲存在不同變數中。
當 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>
-------------------------- 範例 4 --------------------------
</maml:title>
<maml:introduction>
<maml:para>C:\PS></maml:para>
</maml:introduction>
<dev:code>
get-pssession | format-table -property computername, InstanceID
C:\PS> $s = get-pssession -InstanceID a786be29-a6bb-40da-80fb-782c67f7db0f
C:\PS> remove-pssession -session $s </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>在這個範例中,會示範如何利用 PSSession 的執行個體識別碼取得此 PSSession,然後將它刪除。
第一個命令會取得本機電腦的所有 PSSession。它會將這些 PSSession 傳送至 Format-Table Cmdlet,以便顯示每個 PSSession 的 ComputerName 和 InstanceID 屬性。
第二個命令會使用 Get-PSSession Cmdlet 取得特定的 PSSession 並將它儲存在 $s 變數中。這個命令會使用 InstanceID 參數來識別 PSSession。
第三個命令會使用 Remove-PSSession Cmdlet 刪除 $s 變數中的 PSSession。</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>
get-pssession -computername Serv* </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個命令會取得連線至電腦名稱開頭為 "Serv" 之電腦的所有 PSSession。</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>
get-pssession -name Test*, Ux* </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個命令會取得名稱開頭為 "Test" 或 "Ux" 的 PSSession。</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>
-------------------------- 範例 7 --------------------------
</maml:title>
<maml:introduction>
<maml:para>C:\PS></maml:para>
</maml:introduction>
<dev:code>
get-pssession 2 </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個命令會取得識別碼為 2 的 PSSession。</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=135219</maml:uri>
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>about_PSSessions</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>about_Remote</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>New-PSSession</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Remove-PSSession</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Enter-PSSession</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Exit-PSSession</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Invoke-Command</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-PSSessionConfiguration
</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>PSSessionConfiguration</command:noun>
<dev:version></dev:version>
</command:details>
<maml:description>
<maml:para>Get-PSSessionConfiguration Cmdlet 會取得已經在本機電腦上註冊的工作階段設定。這是進階的 Cmdlet,適合系統管理員用來管理使用者的自訂工作階段設定。
若要建立和註冊工作階段設定,請使用 Register-PSSessionConfiguration Cmdlet。</maml:para>
</maml:description>
<!-- Cmdlet syntax section-->
<command:syntax>
<command:syntaxItem>
<maml:name>Get-PSSessionConfiguration</maml:name>
<command:parameter required="false" variableLength="true" globbing="true" pipelineInput="false" position="1">
<maml:name>Name</maml:name>
<maml:description>
<maml:para>只取得具有指定之名稱或名稱模式的工作階段設定。請輸入一個或多個工作階段設定名稱。允許使用萬用字元。</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="false" variableLength="true" globbing="true" pipelineInput="false" position="1">
<maml:name>Name</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: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.Commands.PSSessionConfigurationCommands#PSSessionConfiguration</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>
若要在 Windows Vista、Windows Server 2008 和更新版的 Windows 上執行這個 Cmdlet,您必須使用 [以系統管理員身分執行] 選項開啟 Windows PowerShell。
若要檢視電腦上的工作階段設定,您必須是該電腦上 Administrators 群組的成員。
若要在遠端電腦上執行 Get-PSSessionConfiguration 命令,本機電腦的用戶端設定 (使用 Enable-WSManCredSSP Cmdlet) 以及遠端電腦的服務設定都必須啟用認證安全性服務提供者 (CredSSP) 驗證,而且您必須在建立遠端工作階段時使用 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-pssessionconfiguration </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>
get-pssessionconfiguration -name Microsoft*
Name PSVersion StartupScript Permission
---- --------- ------------- ----------
microsoft.powershell 2.0 BUILTIN\Administrators AccessAll...
microsoft.powershell32 2.0 BUILTIN\Administrators AccessAll... </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個命令會使用 Get-PSSessionConfiguration 的 Name 參數,只取得名稱以 "Microsoft" 為開頭的工作階段設定。
這個命令會取得 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>
Get-PSSessionConfiguration -name microsoft.powershell | get-member
TypeName: Microsoft.PowerShell.Commands.PSSessionConfigurationCommands#PSSessionConfiguration
Name MemberType Definition
---- ---------- ----------
Equals Method bool Equals(System.Object obj)
GetHashCode Method int GetHashCode()
GetType Method type GetType()
ToString Method string ToString()
Capability NoteProperty System.Object[] Capability=System.Object[]
ExactMatch NoteProperty System.String ExactMatch=False
Filename NoteProperty System.String Filename=%windir%\system32\pwrshplugin.dll
lang NoteProperty System.String lang=en-US
Name NoteProperty System.String Name=microsoft.powershell
PSVersion NoteProperty System.String PSVersion=2.0
ResourceUri NoteProperty System.String ResourceUri=http://schemas.microsoft.com/powershell/microsoft.powershell
SDKVersion NoteProperty System.String SDKVersion=1
SecurityDescriptorSddl NoteProperty System.String SecurityDescriptorSddl=O:NSG:BAD:P(A;;GA;;;BA)S:P(AU;FA;GA;;;WD)(AU;SA;GXGW;;;WD)
SupportsOptions NoteProperty System.String SupportsOptions=true
Uri NoteProperty System.String Uri=http://schemas.microsoft.com/powershell/microsoft.powershell
xmlns NoteProperty System.String xmlns=http://schemas.microsoft.com/wbem/wsman/1/config/PluginConfiguration
XmlRenderingType NoteProperty System.String XmlRenderingType=text
Permission ScriptProperty System.Object Permission {get=trap { continue; }...
C:\PS> Get-PSSessionConfiguration -name microsoft.powershell | format-list -property *
Name : microsoft.powershell
Filename : %windir%\system32\pwrshplugin.dll
SDKVersion : 1
XmlRenderingType : text
lang : en-US
PSVersion : 2.0
ResourceUri : http://schemas.microsoft.com/powershell/microsoft.powershell
SupportsOptions : true
Capability : {Shell}
Uri : http://schemas.microsoft.com/powershell/microsoft.powershell
SecurityDescriptorSddl : O:NSG:BAD:P(A;;GA;;;BA)S:P(AU;FA;GA;;;WD)(AU;SA;GXGW;;;WD)
ExactMatch : False
xmlns : http://schemas.microsoft.com/wbem/wsman/1/config/PluginConfiguration
Permission : BUILTIN\Administrators AccessAllowed </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這些命令會檢查 Get-PSSessionConfiguration 所傳回的 PSSessionConfiguration 物件。
第一個命令會使用 Get-PSSessionConfiguration Cmdlet 取得 Microsoft.PowerShell 預設設定。
第二個命令會使用管線運算子 (|),將 Get-PSSessionConfiguration 所傳回的物件傳送給 Get-Member Cmdlet。輸出將顯示該物件的屬性和方法。
第三個命令會將同一個物件傳送給 Format-List Cmdlet。值為 * (全部) 的 Property 參數會指示 Format-List 以清單顯示該物件的所有屬性和屬性值。
這個命令的輸出具有非常有用的資訊,包括實作設定類型之 .dll 的位置、所建立之端點的資源統一資源識別項 (URI),以及設定的安全性描述元定義語言 (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>
-------------------------- 範例 4 --------------------------
</maml:title>
<maml:introduction>
<maml:para>C:\PS></maml:para>
</maml:introduction>
<dev:code>
dir wsman:\localhost\plugin
WSManConfig: Microsoft.WSMan.Management\WSMan::localhost\Plugin
Name Type Keys
---- ---- ----
Event Forwarding Plugin Container {Name=Event Forwarding Plugin}
MaintenanceShell Container {Name=MaintenanceShell}
microsoft.powershell Container {Name=microsoft.powershell}
microsoft.powershell32 Container {Name=microsoft.powershell32}
WMI Provider Container {Name=WMI Provider} </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個命令會在 WSMan: 提供者磁碟機中使用 Get-ChildItem Cmdlet (別名為 dir),以便查看 Plugin 節點的內容。
這是另一種在電腦上查看工作階段設定的方式。
PlugIn 節點包含 ContainerElement 物件 (Microsoft.WSMan.Management.WSManConfigContainerElement),而這些物件代表已註冊的 Windows PowerShell 工作階段設定,以及 WS-Management 的其他外掛程式。</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>
enable-wsmanCredSSP -delegate server02
C:\PS> connect-wsman server02
C:\PS> set-item wsman:\server02*\service\auth\credSSP -value $true
C:\PS> invoke-command -scriptblock {Get-PSSessionConfiguration} -computername Server02 -authentication CredSSP -credential Domain01\Admin01
Name PSVersion StartupScript Permission PSComputerName
---- --------- ------------- ---------- --------------
microsoft.powershell 2.0 BUILTIN\Administrators AccessAll... server02.corp.fabrikam.com
microsoft.powershell32 2.0 BUILTIN\Administrators AccessAll... server02.corp.fabrikam.com
MyX86Shell 2.0 c:\test\x86Shell.ps1 BUILTIN\Administrators AccessAll... server02.corp.fabrikam.com </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個範例會示範如何在遠端電腦上執行 Get-PSSessionConfiguration 命令。此命令要求本機電腦的用戶端設定以及遠端電腦的服務設定都必須啟用 CredSSP 委派。若要執行這個範例中的命令,您必須是本機電腦和遠端電腦上 Administrators 群組的成員。
第一個命令會使用 Enable-WSManCredSSP Cmdlet 來啟用從 Server01 本機電腦到 Server02 遠端電腦的 CredSSP 委派。這個命令會設定本機電腦的 CredSSP 用戶端設定。
第二個命令會使用 Connect-WSMan Cmdlet 來連線到 Server02 電腦。這個動作會將 Server02 電腦的節點新增至本機電腦的 WSMan: 磁碟機,讓您檢視和變更 Server02 電腦的 WS-Management 設定。
第三個命令會使用 Set-Item Cmdlet,將 Server02 電腦之 Service 節點中的 CredSSP 項目值變更為 True。這個命令會設定遠端電腦的服務設定。
第四個命令會使用 Invoke-Command Cmdlet,在 Server02 電腦上執行 Get-PSSessionConfiguration 命令。此命令會使用 Credential 參數,而且它會使用 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:example>
<maml:title>
-------------------------- 範例 6 --------------------------
</maml:title>
<maml:introduction>
<maml:para>C:\PS></maml:para>
</maml:introduction>
<dev:code>
(get-PSSessionConfiguration -name CustomShell).resourceURI
http://schemas.microsoft.com/powershell/microsoft.CustomShell </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個命令會使用 Get-PSSessionConfiguration Cmdlet 來取得工作階段設定的資源 URI。
這個命令可用來設定 $PSSessionConfigurationName 喜好設定變數的值 (採用資源 URI)。
$PSSessionConfiguationName 變數會指定當您建立工作階段時使用的預設設定。雖然這個變數是在本機電腦上設定,不過它會指定遠端電腦上的設定。如需 $PSSessionConfiguration 變數的詳細資訊,請參閱 about_Preference_Variables。</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=144304</maml:uri>
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>about_Session_Configurations</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Disable-PSSessionConfiguration</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Enable-PSSessionConfiguration</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Register-PSSessionConfiguration</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Set-PSSessionConfiguration</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Unregister-PSSessionConfiguration</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>WS-Management Provider</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-PSSnapin
</command:name>
<maml:description>
<maml:para>取得電腦上的 Windows PowerShell 嵌入式管理單元。</maml:para>
</maml:description>
<maml:copyright>
<maml:para></maml:para>
</maml:copyright>
<command:verb>Get</command:verb>
<command:noun>PSSnapin</command:noun>
<dev:version></dev:version>
</command:details>
<maml:description>
<maml:para>Get-PSSnapin Cmdlet 會取得已經新增至目前工作階段或已經在系統上註冊的 Windows PowerShell 嵌入式管理單元。這些嵌入式管理單元會依據偵測順序列出。
Get-PSSnapin 只會取得已註冊的嵌入式管理單元。若要註冊 Windows PowerShell 嵌入式管理單元,請使用 Microsoft .NET Framework 2.0 隨附的 InstallUtil 工具。如需詳細資訊,請參閱 MSDN (Microsoft Developer Network) Library 中的<如何註冊 Cmdlet、提供者和主機應用程式>(英文),網址為:http://go.microsoft.com/fwlink/?LinkId=143619。</maml:para>
</maml:description>
<!-- Cmdlet syntax section-->
<command:syntax>
<command:syntaxItem>
<maml:name>Get-PSSnapin</maml:name>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="false" position="1">
<maml:name>Name</maml:name>
<maml:description>
<maml:para>只取得指定的 Windows PowerShell 嵌入式管理單元。輸入一或多個 Windows PowerShell 嵌入式管理單元的名稱。允許使用萬用字元。
參數名稱 ("Name") 為選擇項。</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>Registered</maml:name>
<maml:description>
<maml:para>取得在系統上已註冊的 Windows PowerShell 嵌入式管理單元 (即使這些嵌入式管理單元尚未新增至工作階段也一樣)。
與 Windows PowerShell 一同安裝的嵌入式管理單元不會出現在此清單中。
如果未指定這個參數,Get-PSSnapin 會取得已新增至此工作階段的 Windows PowerShell 嵌入式管理單元。</maml:para>
</maml:description>
</command:parameter>
</command:syntaxItem>
</command:syntax>
<!-- Cmdlet parameter section -->
<command:parameters>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="false" position="1">
<maml:name>Name</maml:name>
<maml:description>
<maml:para>只取得指定的 Windows PowerShell 嵌入式管理單元。輸入一或多個 Windows PowerShell 嵌入式管理單元的名稱。允許使用萬用字元。
參數名稱 ("Name") 為選擇項。</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>Registered</maml:name>
<maml:description>
<maml:para>取得在系統上已註冊的 Windows PowerShell 嵌入式管理單元 (即使這些嵌入式管理單元尚未新增至工作階段也一樣)。
與 Windows PowerShell 一同安裝的嵌入式管理單元不會出現在此清單中。
如果未指定這個參數,Get-PSSnapin 會取得已新增至此工作階段的 Windows PowerShell 嵌入式管理單元。</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: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 -->
您無法經由管道將輸入輸出至 Get-PSSnapin。
</maml:para>
</maml:description>
</command:inputType>
</command:inputTypes>
<command:returnValues>
<command:returnValue>
<dev:type>
<maml:name>System.Management.Automation.PSSnapInInfo</maml:name>
<maml:uri />
<maml:description />
</dev:type>
<maml:description>
<maml:para>
<!-- description -->
Get-PSSnapin 會針對它所取得的每個嵌入式管理單元傳回一個物件。
</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>
您可以利用內建的別名 "psnp" 來參照 Get-PSSnapin。如需詳細資訊,請參閱 about_Aliases。
</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-PSSnapIn </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個命令會取得目前已載入工作階段中的 Windows PowerShell 嵌入式管理單元。這包含隨 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>
-------------------------- 範例 2 --------------------------
</maml:title>
<maml:introduction>
<maml:para>C:\PS></maml:para>
</maml:introduction>
<dev:code>
get-PSSnapIn -registered </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個命令會取得在電腦上已註冊的 Windows PowerShell 嵌入式管理單元,包括已新增至工作階段的嵌入式管理單元。此時輸出並不包含與 Windows PowerShell 或 Windows PowerShell 嵌入式管理單元動態連結程式庫 (DLL) 一起安裝,但是尚未在系統上註冊的嵌入式管理單元。</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-PSSnapIn smp* </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個命令會取得目前工作階段中名稱開頭為 "smp" 的 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:examples>
<!-- Link section -->
<maml:relatedLinks>
<maml:navigationLink>
<maml:linkText>Online version:</maml:linkText>
<maml:uri>http://go.microsoft.com/fwlink/?LinkID=113330</maml:uri>
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Add-PSSnapin</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Remove-PSSnapin</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>
Import-Module
</command:name>
<maml:description>
<maml:para>將模組新增至目前工作階段。</maml:para>
</maml:description>
<maml:copyright>
<maml:para></maml:para>
</maml:copyright>
<command:verb>Import</command:verb>
<command:noun>Module</command:noun>
<dev:version></dev:version>
</command:details>
<maml:description>
<maml:para>Import-Module Cmdlet 會將一個或多個模組新增至目前的工作階段。
模組是一種封裝,其中包含可用於 Windows PowerShell 的成員 (例如 Cmdlet、提供者、指令碼、函數、變數,以及其他工具與檔案)。匯入模組之後,您就可以在工作階段中使用模組成員。
若要匯入模組,請使用 Name、Assembly 或 ModuleInfo 參數識別要匯入的模組。根據預設,雖然 Import-Module 會匯入模組所匯出的所有成員,不過您可以使用 Alias、Function、Cmdlet 和 Variable 參數來限制要匯入的成員。
Import-Module 只會將模組匯入至目前的工作階段。若要將模組匯入至所有工作階段,請將 Import-Module 命令新增至 Windows PowerShell 設定檔。如需設定檔的詳細資訊,請參閱 about_Profiles。
如需模組的詳細資訊,請參閱 about_Modules。</maml:para>
</maml:description>
<!-- Cmdlet syntax section-->
<command:syntax>
<command:syntaxItem>
<maml:name>Import-Module</maml:name>
<command:parameter required="true" variableLength="true" globbing="false" pipelineInput="true (ByValue)" position="1">
<maml:name>Name</maml:name>
<maml:description>
<maml:para>指定要匯入的模組名稱。請輸入模組的名稱或模組中檔案的名稱,例如 .psd1、.psm1、.dll 或 .ps1 檔案。檔案路徑為選擇項。不允許使用萬用字元。您也可以經由管道將模組名稱和檔案名稱輸出至 Import-Module。
如果您省略路徑,Import-Module 就會在 PSModulePath 環境變數 ($env:PSModulePath) 中儲存的路徑內尋找模組。
請盡可能單獨指定模組名稱。當您指定檔案名稱時,只會匯入該檔案中實作的成員。如果模組包含其他檔案,這些檔案並不會匯入,因此您可能會遺漏模組的重要成員。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="true">string[]</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="true" pipelineInput="false" position="named">
<maml:name>Alias</maml:name>
<maml:description>
<maml:para>只將指定的別名從模組匯入至目前的工作階段。請輸入以逗號分隔的別名清單。允許使用萬用字元。
某些模組會在您匯入時,自動將選取的別名匯出至工作階段。此參數可讓您從匯出的別名中進行選擇。</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>ArgumentList</maml:name>
<maml:description>
<maml:para>指定 Import-Module 命令執行期間傳遞至指令碼模組的引數 (參數值)。此參數只有當您匯入指令碼模組時才有效。
您也可以利用內建的別名 "args" 來參照 ArgumentList。如需詳細資訊,請參閱 about_Aliases。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="true">Object[]</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>AsCustomObject</maml:name>
<maml:description>
<maml:para>傳回自訂物件,其成員表示已匯入的模組成員。此參數只適用於指令碼模組。
使用 AsCustomObject 參數時,Import-Module 會將模組成員匯入至工作階段,然後傳回 PSCustomObject 物件而非 PSModuleInfo 物件。您可以將自訂物件儲存到變數中,並使用點標記法來叫用成員。</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="true" pipelineInput="false" position="named">
<maml:name>Cmdlet</maml:name>
<maml:description>
<maml:para>只將指定的 Cmdlet 從模組匯入至目前的工作階段。請輸入 Cmdlet 的清單。允許使用萬用字元。
某些模組會在您匯入時,自動將選取的 Cmdlet 匯出至工作階段。此參數可讓您從匯出的 Cmdlet 中進行選擇。</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>Force</maml:name>
<maml:description>
<maml:para>重新匯入模組及其成員,即使該模組或其成員具有唯讀的存取模式也一樣。</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="true" pipelineInput="false" position="named">
<maml:name>Function</maml:name>
<maml:description>
<maml:para>只將指定的函數從模組匯入至目前的工作階段。請輸入函數的清單。允許使用萬用字元。
某些模組會在您匯入時,自動將選取的函數匯出至工作階段。此參數可讓您從匯出的函數中進行選擇。</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>Global</maml:name>
<maml:description>
<maml:para>當這個參數用於指令碼模組 (.psm1) 時,它會將模組匯入全域工作階段狀態中。
此參數只有當它出現在指令碼模組時才有效。否則,系統會忽略此參數。
根據預設,指令碼模組中的命令 (包括巢狀模組中的命令) 都會匯入呼叫者的工作階段狀態中。若要限制模組所匯出的命令,請在指令碼模組中使用 Export-ModuleMember 命令。</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>PassThru</maml:name>
<maml:description>
<maml:para>傳回表示已匯入之模組的物件。根據預設,此 Cmdlet 不會產生任何輸出。
附註
-- 當您透過 PassThru 參數,經由管道將 "get-module -listavailable" 命令的輸出輸出至 Import-Module 命令時,Import-Module 會傳回 Get-Module 傳遞給它的物件,但不會更新該物件,因此便尚未填入 Exported 和 NestedModules 屬性。
-- 當您使用 Prefix 參數指定成員的首碼時,首碼並不會出現在模組物件屬性的成員名稱中。物件會記錄套用首碼之前匯出的項目。</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>Prefix</maml:name>
<maml:description>
<maml:para>將指定的首碼新增至已匯入之模組成員名稱中的名詞。
請使用此參數避免名稱衝突,當工作階段中不同成員具有相同名稱時,便可能發生此衝突。這個參數不會變更模組,也不會影響模組為了自行使用而匯入的檔案 (稱為「巢狀模組」)。它只會影響目前工作階段中成員的名稱。
例如,如果您指定首碼 "UTC",然後匯入 Get-Date Cmdlet,則工作階段會將此 Cmdlet 識別為 Get-UTCDate,以免與原始的 Get-Date Cmdlet 混淆。
</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">string</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="true" pipelineInput="false" position="named">
<maml:name>Variable</maml:name>
<maml:description>
<maml:para>只將指定的變數從模組匯入至目前的工作階段。請輸入變數的清單。允許使用萬用字元。
某些模組會在您匯入時,自動將選取的變數匯出至工作階段。此參數可讓您從匯出的變數中進行選擇。</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>Version</maml:name>
<maml:description>
<maml:para>指定要匯入的模組版本。當系統有相同模組的不同版本時,請使用這個參數。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">Version</command:parameterValue>
</command:parameter>
</command:syntaxItem>
<command:syntaxItem>
<maml:name>Import-Module</maml:name>
<command:parameter required="true" variableLength="true" globbing="false" pipelineInput="true (ByValue)" position="1">
<maml:name>Assembly</maml:name>
<maml:description>
<maml:para>匯入在指定之組件物件中實作的 Cmdlet 和提供者。請輸入包含組件物件的變數,或輸入可建立組件物件的命令。您也可以經由管道將組件物件輸出至 Import-Module。
使用此參數時,只會匯入指定之已編譯組件所實作的 Cmdlet 和提供者。如果模組包含其他檔案,這些檔案並不會匯入,因此您可能會遺漏模組的重要成員。請使用此參數來偵錯及測試模組,或是依照模組作者的指示使用此參數。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="true">Assembly[]</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="true" pipelineInput="false" position="named">
<maml:name>Alias</maml:name>
<maml:description>
<maml:para>只將指定的別名從模組匯入至目前的工作階段。請輸入以逗號分隔的別名清單。允許使用萬用字元。
某些模組會在您匯入時,自動將選取的別名匯出至工作階段。此參數可讓您從匯出的別名中進行選擇。</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>ArgumentList</maml:name>
<maml:description>
<maml:para>指定 Import-Module 命令執行期間傳遞至指令碼模組的引數 (參數值)。此參數只有當您匯入指令碼模組時才有效。
您也可以利用內建的別名 "args" 來參照 ArgumentList。如需詳細資訊,請參閱 about_Aliases。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="true">Object[]</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>AsCustomObject</maml:name>
<maml:description>
<maml:para>傳回自訂物件,其成員表示已匯入的模組成員。此參數只適用於指令碼模組。
使用 AsCustomObject 參數時,Import-Module 會將模組成員匯入至工作階段,然後傳回 PSCustomObject 物件而非 PSModuleInfo 物件。您可以將自訂物件儲存到變數中,並使用點標記法來叫用成員。</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="true" pipelineInput="false" position="named">
<maml:name>Cmdlet</maml:name>
<maml:description>
<maml:para>只將指定的 Cmdlet 從模組匯入至目前的工作階段。請輸入 Cmdlet 的清單。允許使用萬用字元。
某些模組會在您匯入時,自動將選取的 Cmdlet 匯出至工作階段。此參數可讓您從匯出的 Cmdlet 中進行選擇。</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>Force</maml:name>
<maml:description>
<maml:para>重新匯入模組及其成員,即使該模組或其成員具有唯讀的存取模式也一樣。</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="true" pipelineInput="false" position="named">
<maml:name>Function</maml:name>
<maml:description>
<maml:para>只將指定的函數從模組匯入至目前的工作階段。請輸入函數的清單。允許使用萬用字元。
某些模組會在您匯入時,自動將選取的函數匯出至工作階段。此參數可讓您從匯出的函數中進行選擇。</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>Global</maml:name>
<maml:description>
<maml:para>當這個參數用於指令碼模組 (.psm1) 時,它會將模組匯入全域工作階段狀態中。
此參數只有當它出現在指令碼模組時才有效。否則,系統會忽略此參數。
根據預設,指令碼模組中的命令 (包括巢狀模組中的命令) 都會匯入呼叫者的工作階段狀態中。若要限制模組所匯出的命令,請在指令碼模組中使用 Export-ModuleMember 命令。</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>PassThru</maml:name>
<maml:description>
<maml:para>傳回表示已匯入之模組的物件。根據預設,此 Cmdlet 不會產生任何輸出。
附註
-- 當您透過 PassThru 參數,經由管道將 "get-module -listavailable" 命令的輸出輸出至 Import-Module 命令時,Import-Module 會傳回 Get-Module 傳遞給它的物件,但不會更新該物件,因此便尚未填入 Exported 和 NestedModules 屬性。
-- 當您使用 Prefix 參數指定成員的首碼時,首碼並不會出現在模組物件屬性的成員名稱中。物件會記錄套用首碼之前匯出的項目。</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>Prefix</maml:name>
<maml:description>
<maml:para>將指定的首碼新增至已匯入之模組成員名稱中的名詞。
請使用此參數避免名稱衝突,當工作階段中不同成員具有相同名稱時,便可能發生此衝突。這個參數不會變更模組,也不會影響模組為了自行使用而匯入的檔案 (稱為「巢狀模組」)。它只會影響目前工作階段中成員的名稱。
例如,如果您指定首碼 "UTC",然後匯入 Get-Date Cmdlet,則工作階段會將此 Cmdlet 識別為 Get-UTCDate,以免與原始的 Get-Date Cmdlet 混淆。
</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">string</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="true" pipelineInput="false" position="named">
<maml:name>Variable</maml:name>
<maml:description>
<maml:para>只將指定的變數從模組匯入至目前的工作階段。請輸入變數的清單。允許使用萬用字元。
某些模組會在您匯入時,自動將選取的變數匯出至工作階段。此參數可讓您從匯出的變數中進行選擇。</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>Version</maml:name>
<maml:description>
<maml:para>指定要匯入的模組版本。當系統有相同模組的不同版本時,請使用這個參數。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">Version</command:parameterValue>
</command:parameter>
</command:syntaxItem>
<command:syntaxItem>
<maml:name>Import-Module</maml:name>
<command:parameter required="true" variableLength="true" globbing="false" pipelineInput="true (ByValue)" position="1">
<maml:name>ModuleInfo</maml:name>
<maml:description>
<maml:para>指定要匯入的模組物件。請輸入包含模組物件的變數,或輸入可取得模組物件的命令,例如 "get-module -listavailable" 命令。您也可以經由管道將模組物件輸出至 Import-Module。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="true">PSModuleInfo[]</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="true" pipelineInput="false" position="named">
<maml:name>Alias</maml:name>
<maml:description>
<maml:para>只將指定的別名從模組匯入至目前的工作階段。請輸入以逗號分隔的別名清單。允許使用萬用字元。
某些模組會在您匯入時,自動將選取的別名匯出至工作階段。此參數可讓您從匯出的別名中進行選擇。</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>ArgumentList</maml:name>
<maml:description>
<maml:para>指定 Import-Module 命令執行期間傳遞至指令碼模組的引數 (參數值)。此參數只有當您匯入指令碼模組時才有效。
您也可以利用內建的別名 "args" 來參照 ArgumentList。如需詳細資訊,請參閱 about_Aliases。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="true">Object[]</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>AsCustomObject</maml:name>
<maml:description>
<maml:para>傳回自訂物件,其成員表示已匯入的模組成員。此參數只適用於指令碼模組。
使用 AsCustomObject 參數時,Import-Module 會將模組成員匯入至工作階段,然後傳回 PSCustomObject 物件而非 PSModuleInfo 物件。您可以將自訂物件儲存到變數中,並使用點標記法來叫用成員。</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="true" pipelineInput="false" position="named">
<maml:name>Cmdlet</maml:name>
<maml:description>
<maml:para>只將指定的 Cmdlet 從模組匯入至目前的工作階段。請輸入 Cmdlet 的清單。允許使用萬用字元。
某些模組會在您匯入時,自動將選取的 Cmdlet 匯出至工作階段。此參數可讓您從匯出的 Cmdlet 中進行選擇。</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>Force</maml:name>
<maml:description>
<maml:para>重新匯入模組及其成員,即使該模組或其成員具有唯讀的存取模式也一樣。</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="true" pipelineInput="false" position="named">
<maml:name>Function</maml:name>
<maml:description>
<maml:para>只將指定的函數從模組匯入至目前的工作階段。請輸入函數的清單。允許使用萬用字元。
某些模組會在您匯入時,自動將選取的函數匯出至工作階段。此參數可讓您從匯出的函數中進行選擇。</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>Global</maml:name>
<maml:description>
<maml:para>當這個參數用於指令碼模組 (.psm1) 時,它會將模組匯入全域工作階段狀態中。
此參數只有當它出現在指令碼模組時才有效。否則,系統會忽略此參數。
根據預設,指令碼模組中的命令 (包括巢狀模組中的命令) 都會匯入呼叫者的工作階段狀態中。若要限制模組所匯出的命令,請在指令碼模組中使用 Export-ModuleMember 命令。</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>PassThru</maml:name>
<maml:description>
<maml:para>傳回表示已匯入之模組的物件。根據預設,此 Cmdlet 不會產生任何輸出。
附註
-- 當您透過 PassThru 參數,經由管道將 "get-module -listavailable" 命令的輸出輸出至 Import-Module 命令時,Import-Module 會傳回 Get-Module 傳遞給它的物件,但不會更新該物件,因此便尚未填入 Exported 和 NestedModules 屬性。
-- 當您使用 Prefix 參數指定成員的首碼時,首碼並不會出現在模組物件屬性的成員名稱中。物件會記錄套用首碼之前匯出的項目。</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>Prefix</maml:name>
<maml:description>
<maml:para>將指定的首碼新增至已匯入之模組成員名稱中的名詞。
請使用此參數避免名稱衝突,當工作階段中不同成員具有相同名稱時,便可能發生此衝突。這個參數不會變更模組,也不會影響模組為了自行使用而匯入的檔案 (稱為「巢狀模組」)。它只會影響目前工作階段中成員的名稱。
例如,如果您指定首碼 "UTC",然後匯入 Get-Date Cmdlet,則工作階段會將此 Cmdlet 識別為 Get-UTCDate,以免與原始的 Get-Date Cmdlet 混淆。
</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">string</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="true" pipelineInput="false" position="named">
<maml:name>Variable</maml:name>
<maml:description>
<maml:para>只將指定的變數從模組匯入至目前的工作階段。請輸入變數的清單。允許使用萬用字元。
某些模組會在您匯入時,自動將選取的變數匯出至工作階段。此參數可讓您從匯出的變數中進行選擇。</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>Version</maml:name>
<maml:description>
<maml:para>指定要匯入的模組版本。當系統有相同模組的不同版本時,請使用這個參數。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">Version</command:parameterValue>
</command:parameter>
</command:syntaxItem>
</command:syntax>
<!-- Cmdlet parameter section -->
<command:parameters>
<command:parameter required="false" variableLength="true" globbing="true" pipelineInput="false" position="named">
<maml:name>Alias</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="true" globbing="false" pipelineInput="false" position="named">
<maml:name>ArgumentList</maml:name>
<maml:description>
<maml:para>指定 Import-Module 命令執行期間傳遞至指令碼模組的引數 (參數值)。此參數只有當您匯入指令碼模組時才有效。
您也可以利用內建的別名 "args" 來參照 ArgumentList。如需詳細資訊,請參閱 about_Aliases。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="true">Object[]</command:parameterValue>
<dev:type>
<maml:name>Object[]</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>AsCustomObject</maml:name>
<maml:description>
<maml:para>傳回自訂物件,其成員表示已匯入的模組成員。此參數只適用於指令碼模組。
使用 AsCustomObject 參數時,Import-Module 會將模組成員匯入至工作階段,然後傳回 PSCustomObject 物件而非 PSModuleInfo 物件。您可以將自訂物件儲存到變數中,並使用點標記法來叫用成員。</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 (ByValue)" position="1">
<maml:name>Assembly</maml:name>
<maml:description>
<maml:para>匯入在指定之組件物件中實作的 Cmdlet 和提供者。請輸入包含組件物件的變數,或輸入可建立組件物件的命令。您也可以經由管道將組件物件輸出至 Import-Module。
使用此參數時,只會匯入指定之已編譯組件所實作的 Cmdlet 和提供者。如果模組包含其他檔案,這些檔案並不會匯入,因此您可能會遺漏模組的重要成員。請使用此參數來偵錯及測試模組,或是依照模組作者的指示使用此參數。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="true">Assembly[]</command:parameterValue>
<dev:type>
<maml:name>Assembly[]</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue></dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="true" pipelineInput="false" position="named">
<maml:name>Cmdlet</maml:name>
<maml:description>
<maml:para>只將指定的 Cmdlet 從模組匯入至目前的工作階段。請輸入 Cmdlet 的清單。允許使用萬用字元。
某些模組會在您匯入時,自動將選取的 Cmdlet 匯出至工作階段。此參數可讓您從匯出的 Cmdlet 中進行選擇。</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>重新匯入模組及其成員,即使該模組或其成員具有唯讀的存取模式也一樣。</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="true" globbing="true" pipelineInput="false" position="named">
<maml:name>Function</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>Global</maml:name>
<maml:description>
<maml:para>當這個參數用於指令碼模組 (.psm1) 時,它會將模組匯入全域工作階段狀態中。
此參數只有當它出現在指令碼模組時才有效。否則,系統會忽略此參數。
根據預設,指令碼模組中的命令 (包括巢狀模組中的命令) 都會匯入呼叫者的工作階段狀態中。若要限制模組所匯出的命令,請在指令碼模組中使用 Export-ModuleMember 命令。</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 (ByValue)" position="1">
<maml:name>ModuleInfo</maml:name>
<maml:description>
<maml:para>指定要匯入的模組物件。請輸入包含模組物件的變數,或輸入可取得模組物件的命令,例如 "get-module -listavailable" 命令。您也可以經由管道將模組物件輸出至 Import-Module。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="true">PSModuleInfo[]</command:parameterValue>
<dev:type>
<maml:name>PSModuleInfo[]</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue></dev:defaultValue>
</command:parameter>
<command:parameter required="true" variableLength="true" globbing="false" pipelineInput="true (ByValue)" position="1">
<maml:name>Name</maml:name>
<maml:description>
<maml:para>指定要匯入的模組名稱。請輸入模組的名稱或模組中檔案的名稱,例如 .psd1、.psm1、.dll 或 .ps1 檔案。檔案路徑為選擇項。不允許使用萬用字元。您也可以經由管道將模組名稱和檔案名稱輸出至 Import-Module。
如果您省略路徑,Import-Module 就會在 PSModulePath 環境變數 ($env:PSModulePath) 中儲存的路徑內尋找模組。
請盡可能單獨指定模組名稱。當您指定檔案名稱時,只會匯入該檔案中實作的成員。如果模組包含其他檔案,這些檔案並不會匯入,因此您可能會遺漏模組的重要成員。</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 不會產生任何輸出。
附註
-- 當您透過 PassThru 參數,經由管道將 "get-module -listavailable" 命令的輸出輸出至 Import-Module 命令時,Import-Module 會傳回 Get-Module 傳遞給它的物件,但不會更新該物件,因此便尚未填入 Exported 和 NestedModules 屬性。
-- 當您使用 Prefix 參數指定成員的首碼時,首碼並不會出現在模組物件屬性的成員名稱中。物件會記錄套用首碼之前匯出的項目。</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>Prefix</maml:name>
<maml:description>
<maml:para>將指定的首碼新增至已匯入之模組成員名稱中的名詞。
請使用此參數避免名稱衝突,當工作階段中不同成員具有相同名稱時,便可能發生此衝突。這個參數不會變更模組,也不會影響模組為了自行使用而匯入的檔案 (稱為「巢狀模組」)。它只會影響目前工作階段中成員的名稱。
例如,如果您指定首碼 "UTC",然後匯入 Get-Date Cmdlet,則工作階段會將此 Cmdlet 識別為 Get-UTCDate,以免與原始的 Get-Date Cmdlet 混淆。
</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="true" pipelineInput="false" position="named">
<maml:name>Variable</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>Version</maml:name>
<maml:description>
<maml:para>指定要匯入的模組版本。當系統有相同模組的不同版本時,請使用這個參數。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">Version</command:parameterValue>
<dev:type>
<maml:name>Version</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、System.Management.Automation.PSModuleInfo 或 System.Reflection.Assembly</maml:name>
<maml:uri />
<maml:description />
</dev:type>
<maml:description>
<maml:para>
<!-- description -->
您可經由管道將模組名稱、模組物件或組件物件輸出至 Import-Module。
</maml:para>
</maml:description>
</command:inputType>
</command:inputTypes>
<command:returnValues>
<command:returnValue>
<dev:type>
<maml:name>無、System.Management.Automation.PSModuleInfo 或 System.Management.Automation.PSCustomObject</maml:name>
<maml:uri />
<maml:description />
</dev:type>
<maml:description>
<maml:para>
<!-- description -->
根據預設,Import-Module 不會產生任何輸出。如果使用 PassThru 參數,它會產生代表模組的 System.Management.Automation.PSModuleInfo 物件。如果使用 AsCustomObject 參數,則會產生 PSCustomObject 物件。
</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>
您也可以利用 Import-Module 的別名 ("ipmo") 來表示此 Cmdlet。如需詳細資訊,請參閱 about_Aliases。
您必須先將模組目錄複製到本機電腦可存取的目錄,然後才能匯入模組。如需詳細資訊,請參閱 about_Modules。
由於模組成員會在自己的私人模組工作階段狀態中執行,因此它們用於內部處理的命令不會影響您的工作階段狀態。
如果您將相同名稱和相同類型的成員匯入至工作階段,Windows PowerShell 預設會使用最後匯入的成員。變數和別名都會被取代,而且其原始項目也會變成無法存取。新成員只會「遮蔽」函數、Cmdlet 和提供者,而且您可以利用嵌入式管理單元、模組或函數路徑來限定命令名稱,以便存取這些項目。
若要更新已經從模組匯入之命令的格式化資料,請使用 Update-FormatData Cmdlet。Update-FormatData 也會在工作階段中更新從模組匯入之命令的格式化資料。如果模組的格式化檔案已變更,您就可以執行 Update-FormatData 命令來更新匯入命令的格式化資料。不過,您不需要再次匯入模組。
若要匯入 Import-PSSession 或 Export-PSSession 所建立的模組,目前工作階段中的執行原則不得為 Restricted 或 AllSigned,因為 Import-PSSession 和 Export-PSSession 所建立的模組包含這些原則禁止使用的未經簽署指令碼檔案。若要使用 Import-Module 而不變更本機電腦的執行原則,請使用 Set-ExecutionPolicy 的 Scope 參數,針對單一處理序設定限制較少的執行原則。
</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>
import-module -name BitsTransfer </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個命令會將 BitsTransfer 模組的成員都匯入至目前的工作階段。
Name 參數名稱 (-Name) 為選擇項,可以省略。
根據預設,Import-Module 不會在匯入模組時產生任何輸出。若要要求輸出,請使用 PassThru 或 AsCustomObject 參數,或是 Verbose 一般參數。</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-module -listAvailable | import-module </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個命令會將 PSModulePath 環境變數 ($env:psmodulepath) 所指定之路徑中的所有可用模組匯入至目前的工作階段。
</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>
$m = get-module -ListAvailable BitsTransfer, ServerBackup
C:\PS> import-module -moduleInfo $m </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個命令會將 BitsTransfer 和 ServerBackup 模組的成員都匯入至目前的工作階段。
第一個命令會使用 Get-Module Cmdlet 取得表示 BitsTransfer 和 ServerBackup 模組的 PSModuleInfo 物件,並將這些物件儲存在 $m 變數中。您必須指定 ListAvailable 參數,才能取得尚未匯入至工作階段的模組。
第二個命令會使用 Import-Module 的 ModuleInfo 參數,將模組匯入至目前的工作階段。
這些命令等同於使用管線運算子 (|) 將 Get-Module 命令的輸出傳送給 Import-Module。</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>
import-module -name c:\ps-test\modules\test -verbose
VERBOSE: Loading module from path 'C:\ps-test\modules\Test\Test.psm1'.
VERBOSE: Exporting function 'my-parm'.
VERBOSE: Exporting function 'get-parm'.
VERBOSE: Exporting function 'get-spec'.
VERBOSE: Exporting function 'get-specDetails'. </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個命令會使用明確的路徑,識別要匯入的模組。
它也會使用 Verbose 一般參數,取得已從模組匯入的項目清單。如果沒有使用 Verbose、PassThru 或 AsCustomObject 參數,Import-Module 就不會在匯入模組時產生任何輸出。</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>
import-module BitsTransfer -cmdlet Add-BitsTransferFile, Get-BitsTransfer
C:\PS> get-module BitsTransfer
Name : BitsTransfer
Path : C:\Windows\system32\WindowsPowerShell\v1.0\Modules\BitsTransfer\BitsTransfer.psd1
Description :
Guid : 8fa5064b-8479-4c5c-86ea-0d311fe48875
Version : 1.0.0.0
ModuleBase : C:\Windows\system32\WindowsPowerShell\v1.0\Modules\BitsTransfer
ModuleType : Manifest
PrivateData :
AccessMode : ReadWrite
ExportedAliases : {}
ExportedCmdlets : {[Add-BitsTransfer, Add-BitsTransfer], [Complete-BitsTransfer, Complete-BitsTransfer], [Get-BitsTransfer, Get-BitsTransfer], [Rem
ove-BitsTransfer, Remove-BitsTransfer]...}
ExportedFunctions : {}
ExportedVariables : {}
NestedModules : {Microsoft.BackgroundIntelligentTransfer.Management}
C:\PS> get-command -module BitsTransfer
CommandType Name Definition
----------- ---- ----------
Cmdlet Add-BitsTransfer Add-BitsTransfer [-BitsJob] <BitsJob[]> [-Source] <String[]> [[-Destination] <String[]>] [-Verbose] [-Debug] [-ErrorA...
Cmdlet Get-BitsTransfer Get-BitsTransfer [[-Name] <String[]>] [-AllUsers] [-Verbose] [-Debug] [-ErrorAction <ActionPreference>] [-WarningActi... </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個範例會示範如何限制匯入工作階段的模組成員,以及這個命令對於工作階段的作用。
第一個命令只會從 BitsTransfer 模組匯入 Add-BitsTransfer 和 Get-BitsTransfer Cmdlet。此命令會使用 Cmdlet 參數來限制模組所匯入的 Cmdlet。您也可以使用 Alias、Variable 和 Function 參數來限制模組所匯入的其他成員。
第二個命令會使用 Get-Module Cmdlet 來取得代表 BitsTransfer 模組的物件。ExportedCmdlets 屬性會列出模組所匯出的所有 Cmdlet,即使沒有全部匯入也一樣。
第三個命令會使用 Get-Command Cmdlet 的 Module 參數來取得已從 BitsTransfer 模組匯入的命令。結果確認只有匯入 Add-BitsTransfer 和 Get-BitsTransfer 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>
-------------------------- 範例 6 --------------------------
</maml:title>
<maml:introduction>
<maml:para>C:\PS></maml:para>
</maml:introduction>
<dev:code>
import-module BitsTransfer -prefix PS -passthru
Name : bitstransfer
Path : C:\Windows\system32\WindowsPowerShell\v1.0\Modules\bitstransfer\bitstransfer.psd1
Description :
Guid : 8fa5064b-8479-4c5c-86ea-0d311fe48875
Version : 1.0.0.0
ModuleBase : C:\Windows\system32\WindowsPowerShell\v1.0\Modules\bitstransfer
ModuleType : Manifest
PrivateData :
AccessMode : ReadWrite
ExportedAliases : {}
ExportedCmdlets : {[Add-BitsTransfer, Add-BitsTransfer], [Remove-BitsTransfer, Remove-BitsTransfer], [Complete-BitsTransfer, Complete-BitsTransfer]
, [Get-BitsTransfer, Get-BitsTransfer]...}
ExportedFunctions : {}
ExportedVariables : {}
NestedModules : {Microsoft.BackgroundIntelligentTransfer.Management}
C:\PS> get-command -module bitstransfer
CommandType Name Definition
----------- ---- ----------
Cmdlet Add-PSBitsTransfer Add-PSBitsTransfer [-BitsJob] <BitsJob[]> [-Source] <String[]> ...
Cmdlet Complete-PSBitsTransfer Complete-PSBitsTransfer [-BitsJob] <BitsJob[]> [-Verbose] [-Deb...
Cmdlet Get-PSBitsTransfer Get-PSBitsTransfer [[-Name] <String[]>] [-AllUsers] [-Verbose] ...
Cmdlet Remove-PSBitsTransfer Remove-PSBitsTransfer [-BitsJob] <BitsJob[]> [-Verbose] [-Debug...
Cmdlet Resume-PSBitsTransfer Resume-PSBitsTransfer [-BitsJob] <BitsJob[]> [-Asynchronous] [-...
Cmdlet Set-PSBitsTransfer Set-PSBitsTransfer [-BitsJob] <BitsJob[]> [-DisplayName <String...
Cmdlet Start-PSBitsTransfer Start-PSBitsTransfer [[-Source] <String[]>] [[-Destination] <St...
Cmdlet Suspend-PSBitsTransfer Suspend-PSBitsTransfer [-BitsJob] <BitsJob[]> [-Verbose] [-Debu... </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這些命令會將 BitsTransfer 模組匯入至目前的工作階段、將首碼新增至成員名稱,然後顯示加上首碼的成員名稱。
第一個命令會使用 Import-Module Cmdlet 匯入 BitsTransfer 模組,並使用 Prefix 參數將 PS 首碼新增至從模組匯入的所有成員,以及使用 PassThru 參數傳回表示已匯入之模組的模組物件。
此命令傳回的模組物件具有 ExportedCmdlets 屬性,它會列出已匯出的成員。首碼不會出現在 Cmdlet 名稱中,因為成員是在匯出之後 (但在匯入之前) 才套用首碼。
第二個命令會使用 Get-Command Cmdlet 取得已經從模組匯入的成員,並使用 Module 參數指定模組。輸出顯示模組成員都已正確加上首碼。
您所使用的首碼只會套用至目前工作階段中的成員,它並不會變更模組。</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>
-------------------------- 範例 7 --------------------------
</maml:title>
<maml:introduction>
<maml:para>C:\PS></maml:para>
</maml:introduction>
<dev:code>
get-module -list | format-table -property name, moduletype -auto
Name ModuleType
---- ----------
Show-Calendar Script
BitsTransfer Manifest
PSDiagnostics Manifest
TestCmdlets Script
C:\PS> $a = import-module -name Show-Calendar -asCustomObject
C:\PS> $a | get-member
TypeName: System.Management.Automation.PSCustomObject
Name MemberType Definition
---- ---------- ----------
Equals Method bool Equals(System.Object obj)
GetHashCode Method int GetHashCode()
GetType Method type GetType()
ToString Method string ToString()
Show-Calendar ScriptMethod System.Object Show-Calendar();
C:\PS> $a."show-calendar"() </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這些命令會示範如何取得及使用 Import-Module 傳回的自訂物件。
自訂物件包括綜合成員,其代表每個已匯入的模組成員。例如,模組中的 Cmdlet 和函數會轉換成自訂物件的指令碼方法。
自訂物件在撰寫指令碼時非常有用。當匯入的多個物件具有相同名稱時,自訂物件也很有用。使用物件的指令碼方法等同於指定已匯入成員的完整名稱,包括其模組名稱。
AsCustomObject 參數只能與指令碼模組一起使用,因此首要工作是判斷哪個可用模組是指令碼模組。
第一個命令會使用 Get-Module Cmdlet 取得可用的模組,並使用管線運算子 (|) 將模組物件傳遞至 Format-Table Cmdlet,而此 Cmdlet 會將每個模組的 Name 和 ModuleType 列在一份表格中。
第二個命令會使用 Import-Module Cmdlet 匯入 Show-Calendar 指令碼模組,並使用 AsCustomObject 參數來要求自訂物件,再將產生的自訂物件儲存在 $a 變數中。
第三個命令會使用管線運算子將 $a 變數傳送給 Get-Member Cmdlet,此 Cmdlet 會取得 $a 中 PSCustomObject 的屬性和方法。輸出顯示 Show-Calendar 指令碼方法。
最後一個命令會使用 Show-Calendar 指令碼方法。因為方法名稱包含連字號,所以必須置於引號中。</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>
-------------------------- 範例 8 --------------------------
</maml:title>
<maml:introduction>
<maml:para>C:\PS></maml:para>
</maml:introduction>
<dev:code>
import-module BitsTransfer
C:\PS> import-module BitsTransfer -force -prefix PS </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個範例會示範如何在您將模組重新匯入相同的工作階段時使用 Import-Module 的 Force 參數。
第一個命令會匯入 BitsTransfer 模組。第二個命令會再次匯入此模組,但這次會使用 Prefix 參數。
第二個命令也會包含 Force 參數,以便移除模組,然後再次匯入。如果沒有使用此參數,工作階段的每個 BitsTransfer 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>
-------------------------- 範例 9 --------------------------
</maml:title>
<maml:introduction>
<maml:para>C:\PS></maml:para>
</maml:introduction>
<dev:code>
get-date
Saturday, September 12, 2009 6:47:04 PM
C:\PS> import-module TestModule
C:\PS> get-date
09255
C:\PS> get-command get-date | format-table -property commandtype, name, pssnapin, module -auto
CommandType Name pssnapin Module
----------- ---- -------- ------
Function Get-Date TestModule
Cmdlet Get-Date Microsoft.PowerShell.Utility
C:\PS> Microsoft.PowerShell.Utility\get-date
Saturday, September 12, 2009 6:33:23 PM </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個範例會示範如何執行匯入之命令已經隱藏的命令。
第一個命令會執行 Windows PowerShell 隨附的 Get-Date Cmdlet。它會傳回具有目前日期的 DateTime 物件。
第二個命令會匯入 TestModule 模組。這個模組包含名為 Get-Date 的函數,可傳回 Julian 日期。
第三個命令會再次執行 Get-Date 命令。因為函數的優先順序高於 Cmdlet,所以系統會執行 TestModule 模組的 Get-Date 函數而非 Get-Date Cmdlet。
第四個命令顯示,工作階段中存在兩個 Get-Date 命令:TestModule 模組的函數以及 Microsoft.PowerShell.Utility 嵌入式管理單元的 Cmdlet。
第五個命令會使用嵌入式管理單元名稱來限定命令名稱,藉以執行隱藏的 Cmdlet。
如需 Windows PowerShell 中命令優先順序的詳細資訊,請參閱 about_command_precedence。</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=141553</maml:uri>
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Get-Module</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>New-Module</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Remove-Module</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Export-ModuleMember</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>about_Modules</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>
Invoke-Command
</command:name>
<maml:description>
<maml:para>在本機和遠端電腦執行命令。</maml:para>
</maml:description>
<maml:copyright>
<maml:para></maml:para>
</maml:copyright>
<command:verb>Invoke</command:verb>
<command:noun>Command</command:noun>
<dev:version></dev:version>
</command:details>
<maml:description>
<maml:para>Invoke-Command Cmdlet 會在本機或遠端電腦執行命令,並傳回命令的所有輸出,包括錯誤。您可以使用單一的 Invoke-Command 命令,在多部電腦執行命令。
若要在遠端電腦執行單一命令,請使用 ComputerName 參數。若要執行共用資料的一系列相關命令,請在遠端電腦建立 PSSession (固定連線),然後使用 Invoke-Command 的 Session 參數在 PSSession 中執行命令。
您也可以在本機電腦使用 Invoke-Command,將指令碼區塊中的字串當做命令來評估或執行。Windows PowerShell 會將指令碼區塊轉換成命令,並立即在目前的範圍中執行命令,而不是只在命令列中回應該字串。
使用 Invoke-Command 在遠端電腦執行命令之前,請參閱 about_Remote。</maml:para>
</maml:description>
<!-- Cmdlet syntax section-->
<command:syntax>
<command:syntaxItem>
<maml:name>Invoke-Command</maml:name>
<command:parameter required="true" variableLength="false" globbing="false" pipelineInput="false" position="2">
<maml:name>ScriptBlock</maml:name>
<maml:description>
<maml:para>指定要執行的命令。請以大括號 ( { } ) 括住命令以建立指令碼區塊。此參數為必要項。
根據預設,命令中的所有變數都會在遠端電腦進行評估。若要在命令中加上區域變數,請使用 ArgumentList 參數。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">scriptblock</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="true (ByPropertyName)" position="1">
<maml:name>ComputerName</maml:name>
<maml:description>
<maml:para>指定執行命令的電腦。預設為本機電腦。
使用 ComputerName 參數時,Windows PowerShell 會建立暫時連線,這個連線在執行完指定的命令之後便會關閉。如果您需要固定連線,請使用 Session 參數。
請在清單中以逗號分隔的方式,輸入一部或多部電腦的 NETBIOS 名稱、IP 位址或完整網域名稱。若要指定本機電腦,請輸入電腦名稱、"localhost" 或點 (.)。
若要在 ComputerName 參數的值中使用 IP 位址,命令必須包含 Credential 參數。而且,該電腦必須設定成 HTTPS 傳輸,或者遠端電腦的 IP 位址必須包含在本機電腦的 WinRM TrustedHosts 清單中。如需將電腦名稱新增到 TrustedHosts 清單的指示,請參閱 about_Remote_Troubleshooting 中的<如何將電腦新增到信任的主機清單>。
注意:在 Windows Vista 和更新版的 Windows 上,若要在 ComputerName 參數值中包含本機電腦,您必須以 [以系統管理員身分執行] 選項開啟 Windows PowerShell。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="true">string[]</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="true (ByPropertyName)" position="named">
<maml:name>ApplicationName</maml:name>
<maml:description>
<maml:para>指定連線 URI 的應用程式名稱區段。當您沒有在命令中使用 ConnectionURI 參數時,可以使用此參數指定應用程式名稱。
預設值為本機電腦上的 $PSSessionApplicationName 喜好設定變數的值。如果沒有定義此喜好設定變數,則預設值為 WSMAN。這個值適合大部分使用情況。如需詳細資訊,請參閱 about_Preference_Variables。
WinRM 服務會使用應用程式名稱來選取要服務連線要求的接聽程式。這個參數的值必須符合遠端電腦上接聽程式的 URLPrefix 屬性值。</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>AsJob</maml:name>
<maml:description>
<maml:para>在遠端電腦將背景工作當做命令來執行。此參數可以用來執行需時甚久才能完成的命令。
使用 AsJob 時,此命令會傳回表示工作的物件,然後顯示命令提示字元。工作完成時,您可以繼續在工作階段中執行工作。若要管理工作,請使用各項 Job Cmdlet。若要取得工作結果,請使用 Receive-Job。
AsJob 參數的作用,與使用 Invoke-Command 從遠端執行 Start-Job 命令類似。然而,配搭 AsJob 時,即使工作是在遠端電腦執行,但仍是在本機電腦建立工作。此外,遠端工作的結果也會自動傳回到本機電腦。
如需 Windows PowerShell 背景工作的詳細資訊,請參閱 about_Jobs 和 about_Remote_Jobs。</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>Authentication</maml:name>
<maml:description>
<maml:para>指定用來驗證使用者認證的機制。有效值為 Default、Basic、Credssp、Digest、Kerberos、Negotiate 和 NegotiateWithImplicitCredential。預設值為 Default。
CredSSP 驗證僅適用於 Windows Vista、Windows Server 2008 和更新版的 Windows。
如需此參數之值的詳細資訊,請參閱 MSDN 中的 System.Management.Automation.Runspaces.AuthenticationMechanism 列舉說明。
警告:認證安全性服務提供者 (CredSSP) 驗證 (其中使用者的認證會傳送到遠端電腦) 是專為需要對一個以上的資源進行驗證的命令所設計,例如存取遠端網路共用。此機制會提高遠端操作的安全性風險。如果遠端電腦已經遭受危害,則傳遞給遠端電腦的認證可能會被用來控制網路工作階段。</maml:para>
</maml:description>
<command:parameterValueGroup>
<command:parameterValue required="false" variableLength="false">Default</command:parameterValue>
<command:parameterValue required="false" variableLength="false">Basic</command:parameterValue>
<command:parameterValue required="false" variableLength="false">Negotiate</command:parameterValue>
<command:parameterValue required="false" variableLength="false">NegotiateWithImplicitCredential</command:parameterValue>
<command:parameterValue required="false" variableLength="false">Credssp</command:parameterValue>
<command:parameterValue required="false" variableLength="false">Digest</command:parameterValue>
<command:parameterValue required="false" variableLength="false">Kerberos</command:parameterValue>
</command:parameterValueGroup>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>CertificateThumbprint</maml:name>
<maml:description>
<maml:para>對於具有執行此動作之權限的使用者帳戶,指定其數位公開金鑰憑證 (X509)。請輸入憑證的憑證指紋。
憑證係在進行用戶端憑證式驗證時使用。這些憑證只能對應到本機使用者帳戶,並不適用於網域帳戶。
若要取得憑證指紋,請在 Windows PowerShell 的 Cert: 磁碟機中使用 Get-Item 或 Get-ChildItem 命令。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">string</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="true (ByPropertyName)" position="named">
<maml:name>ConfigurationName</maml:name>
<maml:description>
<maml:para>指定用於新 PSSession 的工作階段設定。
請輸入工作階段設定的設定名稱或完整資源 URI。如果只指定設定名稱,則會在其前面加上下列結構描述 URI:http://schemas.microsoft.com/powershell。
工作階段的工作階段設定是位於遠端電腦。如果遠端電腦上沒有指定的工作階段設定,則命令會失敗。
預設值為本機電腦上的 $PSSessionConfigurationName 喜好設定變數的值。如果沒有設定此喜好設定變數,則預設值為 Microsoft.PowerShell。如需詳細資訊,請參閱 about_preference_variables。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">string</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="true (ByPropertyName)" position="named">
<maml:name>Credential</maml:name>
<maml:description>
<maml:para>指定具有執行此動作之權限的使用者帳戶。預設為目前使用者。
請輸入使用者名稱,例如 "User01" 或 "Domain01\User01",或是輸入含 PSCredential 物件的變數,例如 Get-Credential Cmdlet 所產生的物件。當您輸入使用者名稱時,會提示您輸入密碼。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">PSCredential</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>HideComputerName</maml:name>
<maml:description>
<maml:para>在輸出顯示中省略每一個物件的電腦名稱。根據預設,螢幕上會顯示產生物件的電腦名稱。
此參數只對輸出顯示有影響,而不會變更物件。</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>JobName</maml:name>
<maml:description>
<maml:para>指定好記的背景工作名稱。根據預設,工作會命名為 "Job<n>",其中 <n> 為序數。此參數只能與 AsJob 參數搭配使用。
如果您在命令中使用 JobName 參數,則會將命令當成工作來執行,且 Invoke-Command 會傳回工作物件,即使命令中不包含 AsJob 參數也是如此。
如需 Windows PowerShell 背景工作的詳細資訊,請參閱 about_Jobs。</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>Port</maml:name>
<maml:description>
<maml:para>指定遠端電腦上要供此命令使用的網路連接埠。預設為連接埠 80 (HTTP 連接埠)。
使用其他連接埠之前,必須先於遠端電腦上設定 WinRM 接聽程式,以接聽該連接埠。若要設定接聽程式,請在 Windows PowerShell 提示字元中輸入下列兩個命令:
remove-item -path wsman:\Localhost\listener\listener* -recurse
new-item -path wsman:\Localhost\listener -Transport http -Address * -port <連接埠號碼>
除非必要,否則請勿使用 Port 參數。命令中的 Port 設定適用於執行命令的所有電腦或工作階段。其他連接埠設定可能會導致無法在所有電腦上執行命令。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">int</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>SessionOption</maml:name>
<maml:description>
<maml:para>設定工作階段的進階選項。請輸入使用 New-PSSessionOption Cmdlet 所建立的 SessionOption 物件。
如果有設定 $PSSessionOption 喜好設定變數的值,它會決定選項的預設值。否則,工作階段會使用系統預設值。
如需工作階段選項 (包括預設值) 的描述,請參閱 New-PSSessionOption Cmdlet 的說明主題。如需 $PSSessionOption 喜好設定變數的詳細資訊,請參閱 about_Preference_Variables。
</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">PSSessionOption</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>ThrottleLimit</maml:name>
<maml:description>
<maml:para>指定可以建立以執行此命令之同時連線數目的上限。如果您省略這個參數或輸入 0 這個值,則會使用預設值 32。
節流閥限制只適用於目前的命令,並不適用於工作階段或電腦。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">int</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>UseSSL</maml:name>
<maml:description>
<maml:para>使用安全通訊端層 (SSL) 通訊協定建立與遠端電腦的連線。預設不會使用 SSL,
因為 WS-Management 會將所有透過網路傳輸的 Windows PowerShell 內容加密。使用 UseSSL 時,便會透過 HTTPS (而非 HTTP) 傳送資料,提供多一層防護。
如果使用此參數,但是供命令使用的連接埠無法使用 SSL,則命令會失敗。</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="false" position="named">
<maml:name>ArgumentList</maml:name>
<maml:description>
<maml:para>提供命令中的區域變數值。在遠端電腦執行命令之前,這些值會取代命令中的變數。請在清單中輸入以逗號分隔的值。這些值會依照列出的順序與變數產生關聯。ArgumentList 的別名為 "Args"。
ArgumentList 中的值可以是實際值 (如 "1024") 或是區域變數的參考 (如 "$max")。
若要在命令中使用區域變數,請採用下列命令格式:
{param($<name1>[, $<name2>]...)<command-with-local-variables>} -ArgumentList <value | $local-variable>
"param" 關鍵字會列出命令中使用的區域變數。ArgumentList 參數會依照變數的列出順序提供變數值。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="true">Object[]</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="true (ByValue)" position="named">
<maml:name>InputObject</maml:name>
<maml:description>
<maml:para>指定命令的輸入。請輸入包含物件的變數,或輸入可取得物件的命令或運算式。
使用 InputObject 時,請在 ScriptBlock 參數的值中使用 $input 自動變數,以表示輸入物件。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">psobject</command:parameterValue>
</command:parameter>
</command:syntaxItem>
<command:syntaxItem>
<maml:name>Invoke-Command</maml:name>
<command:parameter required="true" variableLength="false" globbing="false" pipelineInput="false" position="2">
<maml:name>FilePath</maml:name>
<maml:description>
<maml:para>在一部或多部遠端電腦上執行指定的本機指令碼。請輸入指令碼的路徑和檔名,或經由管道將指令碼路徑輸出至 Invoke-Command。此指令碼必須存在於本機電腦或本機電腦可存取的目錄中。請使用 ArgumentList 參數指定指令碼中參數的值。
使用此參數時,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="true (ByPropertyName)" position="1">
<maml:name>ComputerName</maml:name>
<maml:description>
<maml:para>指定執行命令的電腦。預設為本機電腦。
使用 ComputerName 參數時,Windows PowerShell 會建立暫時連線,這個連線在執行完指定的命令之後便會關閉。如果您需要固定連線,請使用 Session 參數。
請在清單中以逗號分隔的方式,輸入一部或多部電腦的 NETBIOS 名稱、IP 位址或完整網域名稱。若要指定本機電腦,請輸入電腦名稱、"localhost" 或點 (.)。
若要在 ComputerName 參數的值中使用 IP 位址,命令必須包含 Credential 參數。而且,該電腦必須設定成 HTTPS 傳輸,或者遠端電腦的 IP 位址必須包含在本機電腦的 WinRM TrustedHosts 清單中。如需將電腦名稱新增到 TrustedHosts 清單的指示,請參閱 about_Remote_Troubleshooting 中的<如何將電腦新增到信任的主機清單>。
注意:在 Windows Vista 和更新版的 Windows 上,若要在 ComputerName 參數值中包含本機電腦,您必須以 [以系統管理員身分執行] 選項開啟 Windows PowerShell。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="true">string[]</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="true (ByPropertyName)" position="named">
<maml:name>ApplicationName</maml:name>
<maml:description>
<maml:para>指定連線 URI 的應用程式名稱區段。當您沒有在命令中使用 ConnectionURI 參數時,可以使用此參數指定應用程式名稱。
預設值為本機電腦上的 $PSSessionApplicationName 喜好設定變數的值。如果沒有定義此喜好設定變數,則預設值為 WSMAN。這個值適合大部分使用情況。如需詳細資訊,請參閱 about_Preference_Variables。
WinRM 服務會使用應用程式名稱來選取要服務連線要求的接聽程式。這個參數的值必須符合遠端電腦上接聽程式的 URLPrefix 屬性值。</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>AsJob</maml:name>
<maml:description>
<maml:para>在遠端電腦將背景工作當做命令來執行。此參數可以用來執行需時甚久才能完成的命令。
使用 AsJob 時,此命令會傳回表示工作的物件,然後顯示命令提示字元。工作完成時,您可以繼續在工作階段中執行工作。若要管理工作,請使用各項 Job Cmdlet。若要取得工作結果,請使用 Receive-Job。
AsJob 參數的作用,與使用 Invoke-Command 從遠端執行 Start-Job 命令類似。然而,配搭 AsJob 時,即使工作是在遠端電腦執行,但仍是在本機電腦建立工作。此外,遠端工作的結果也會自動傳回到本機電腦。
如需 Windows PowerShell 背景工作的詳細資訊,請參閱 about_Jobs 和 about_Remote_Jobs。</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>Authentication</maml:name>
<maml:description>
<maml:para>指定用來驗證使用者認證的機制。有效值為 Default、Basic、Credssp、Digest、Kerberos、Negotiate 和 NegotiateWithImplicitCredential。預設值為 Default。
CredSSP 驗證僅適用於 Windows Vista、Windows Server 2008 和更新版的 Windows。
如需此參數之值的詳細資訊,請參閱 MSDN 中的 System.Management.Automation.Runspaces.AuthenticationMechanism 列舉說明。
警告:認證安全性服務提供者 (CredSSP) 驗證 (其中使用者的認證會傳送到遠端電腦) 是專為需要對一個以上的資源進行驗證的命令所設計,例如存取遠端網路共用。此機制會提高遠端操作的安全性風險。如果遠端電腦已經遭受危害,則傳遞給遠端電腦的認證可能會被用來控制網路工作階段。</maml:para>
</maml:description>
<command:parameterValueGroup>
<command:parameterValue required="false" variableLength="false">Default</command:parameterValue>
<command:parameterValue required="false" variableLength="false">Basic</command:parameterValue>
<command:parameterValue required="false" variableLength="false">Negotiate</command:parameterValue>
<command:parameterValue required="false" variableLength="false">NegotiateWithImplicitCredential</command:parameterValue>
<command:parameterValue required="false" variableLength="false">Credssp</command:parameterValue>
<command:parameterValue required="false" variableLength="false">Digest</command:parameterValue>
<command:parameterValue required="false" variableLength="false">Kerberos</command:parameterValue>
</command:parameterValueGroup>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="true (ByPropertyName)" position="named">
<maml:name>ConfigurationName</maml:name>
<maml:description>
<maml:para>指定用於新 PSSession 的工作階段設定。
請輸入工作階段設定的設定名稱或完整資源 URI。如果只指定設定名稱,則會在其前面加上下列結構描述 URI:http://schemas.microsoft.com/powershell。
工作階段的工作階段設定是位於遠端電腦。如果遠端電腦上沒有指定的工作階段設定,則命令會失敗。
預設值為本機電腦上的 $PSSessionConfigurationName 喜好設定變數的值。如果沒有設定此喜好設定變數,則預設值為 Microsoft.PowerShell。如需詳細資訊,請參閱 about_preference_variables。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">string</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="true (ByPropertyName)" position="named">
<maml:name>Credential</maml:name>
<maml:description>
<maml:para>指定具有執行此動作之權限的使用者帳戶。預設為目前使用者。
請輸入使用者名稱,例如 "User01" 或 "Domain01\User01",或是輸入含 PSCredential 物件的變數,例如 Get-Credential Cmdlet 所產生的物件。當您輸入使用者名稱時,會提示您輸入密碼。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">PSCredential</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>HideComputerName</maml:name>
<maml:description>
<maml:para>在輸出顯示中省略每一個物件的電腦名稱。根據預設,螢幕上會顯示產生物件的電腦名稱。
此參數只對輸出顯示有影響,而不會變更物件。</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>JobName</maml:name>
<maml:description>
<maml:para>指定好記的背景工作名稱。根據預設,工作會命名為 "Job<n>",其中 <n> 為序數。此參數只能與 AsJob 參數搭配使用。
如果您在命令中使用 JobName 參數,則會將命令當成工作來執行,且 Invoke-Command 會傳回工作物件,即使命令中不包含 AsJob 參數也是如此。
如需 Windows PowerShell 背景工作的詳細資訊,請參閱 about_Jobs。</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>Port</maml:name>
<maml:description>
<maml:para>指定遠端電腦上要供此命令使用的網路連接埠。預設為連接埠 80 (HTTP 連接埠)。
使用其他連接埠之前,必須先於遠端電腦上設定 WinRM 接聽程式,以接聽該連接埠。若要設定接聽程式,請在 Windows PowerShell 提示字元中輸入下列兩個命令:
remove-item -path wsman:\Localhost\listener\listener* -recurse
new-item -path wsman:\Localhost\listener -Transport http -Address * -port <連接埠號碼>
除非必要,否則請勿使用 Port 參數。命令中的 Port 設定適用於執行命令的所有電腦或工作階段。其他連接埠設定可能會導致無法在所有電腦上執行命令。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">int</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>SessionOption</maml:name>
<maml:description>
<maml:para>設定工作階段的進階選項。請輸入使用 New-PSSessionOption Cmdlet 所建立的 SessionOption 物件。
如果有設定 $PSSessionOption 喜好設定變數的值,它會決定選項的預設值。否則,工作階段會使用系統預設值。
如需工作階段選項 (包括預設值) 的描述,請參閱 New-PSSessionOption Cmdlet 的說明主題。如需 $PSSessionOption 喜好設定變數的詳細資訊,請參閱 about_Preference_Variables。
</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">PSSessionOption</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>ThrottleLimit</maml:name>
<maml:description>
<maml:para>指定可以建立以執行此命令之同時連線數目的上限。如果您省略這個參數或輸入 0 這個值,則會使用預設值 32。
節流閥限制只適用於目前的命令,並不適用於工作階段或電腦。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">int</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>UseSSL</maml:name>
<maml:description>
<maml:para>使用安全通訊端層 (SSL) 通訊協定建立與遠端電腦的連線。預設不會使用 SSL,
因為 WS-Management 會將所有透過網路傳輸的 Windows PowerShell 內容加密。使用 UseSSL 時,便會透過 HTTPS (而非 HTTP) 傳送資料,提供多一層防護。
如果使用此參數,但是供命令使用的連接埠無法使用 SSL,則命令會失敗。</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="false" position="named">
<maml:name>ArgumentList</maml:name>
<maml:description>
<maml:para>提供命令中的區域變數值。在遠端電腦執行命令之前,這些值會取代命令中的變數。請在清單中輸入以逗號分隔的值。這些值會依照列出的順序與變數產生關聯。ArgumentList 的別名為 "Args"。
ArgumentList 中的值可以是實際值 (如 "1024") 或是區域變數的參考 (如 "$max")。
若要在命令中使用區域變數,請採用下列命令格式:
{param($<name1>[, $<name2>]...)<command-with-local-variables>} -ArgumentList <value | $local-variable>
"param" 關鍵字會列出命令中使用的區域變數。ArgumentList 參數會依照變數的列出順序提供變數值。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="true">Object[]</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="true (ByValue)" position="named">
<maml:name>InputObject</maml:name>
<maml:description>
<maml:para>指定命令的輸入。請輸入包含物件的變數,或輸入可取得物件的命令或運算式。
使用 InputObject 時,請在 ScriptBlock 參數的值中使用 $input 自動變數,以表示輸入物件。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">psobject</command:parameterValue>
</command:parameter>
</command:syntaxItem>
<command:syntaxItem>
<maml:name>Invoke-Command</maml:name>
<command:parameter required="true" variableLength="false" globbing="false" pipelineInput="false" position="2">
<maml:name>FilePath</maml:name>
<maml:description>
<maml:para>在一部或多部遠端電腦上執行指定的本機指令碼。請輸入指令碼的路徑和檔名,或經由管道將指令碼路徑輸出至 Invoke-Command。此指令碼必須存在於本機電腦或本機電腦可存取的目錄中。請使用 ArgumentList 參數指定指令碼中參數的值。
使用此參數時,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="true (ByPropertyName)" position="1">
<maml:name>Session</maml:name>
<maml:description>
<maml:para>在指定的 Windows PowerShell 工作階段 (PSSession) 中執行命令。請輸入包含 PSSession 的變數,或者輸入建立或取得 PSSession 的命令,例如 New-PSSession 或 Get-PSSession 命令。
建立 PSSession 時,Windows PowerShell 會建立與遠端電腦之間的固定連線。請使用 PSSession 來執行共用資料的一系列相關命令。若要執行單一命令或一系列相關命令,請使用 ComputerName 參數。
若要建立 PSSession,請使用 New-PSSession Cmdlet。如需詳細資訊,請參閱 about_PSSessions。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="true">PSSession[]</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>AsJob</maml:name>
<maml:description>
<maml:para>在遠端電腦將背景工作當做命令來執行。此參數可以用來執行需時甚久才能完成的命令。
使用 AsJob 時,此命令會傳回表示工作的物件,然後顯示命令提示字元。工作完成時,您可以繼續在工作階段中執行工作。若要管理工作,請使用各項 Job Cmdlet。若要取得工作結果,請使用 Receive-Job。
AsJob 參數的作用,與使用 Invoke-Command 從遠端執行 Start-Job 命令類似。然而,配搭 AsJob 時,即使工作是在遠端電腦執行,但仍是在本機電腦建立工作。此外,遠端工作的結果也會自動傳回到本機電腦。
如需 Windows PowerShell 背景工作的詳細資訊,請參閱 about_Jobs 和 about_Remote_Jobs。</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>HideComputerName</maml:name>
<maml:description>
<maml:para>在輸出顯示中省略每一個物件的電腦名稱。根據預設,螢幕上會顯示產生物件的電腦名稱。
此參數只對輸出顯示有影響,而不會變更物件。</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>JobName</maml:name>
<maml:description>
<maml:para>指定好記的背景工作名稱。根據預設,工作會命名為 "Job<n>",其中 <n> 為序數。此參數只能與 AsJob 參數搭配使用。
如果您在命令中使用 JobName 參數,則會將命令當成工作來執行,且 Invoke-Command 會傳回工作物件,即使命令中不包含 AsJob 參數也是如此。
如需 Windows PowerShell 背景工作的詳細資訊,請參閱 about_Jobs。</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>ThrottleLimit</maml:name>
<maml:description>
<maml:para>指定可以建立以執行此命令之同時連線數目的上限。如果您省略這個參數或輸入 0 這個值,則會使用預設值 32。
節流閥限制只適用於目前的命令,並不適用於工作階段或電腦。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">int</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="false" position="named">
<maml:name>ArgumentList</maml:name>
<maml:description>
<maml:para>提供命令中的區域變數值。在遠端電腦執行命令之前,這些值會取代命令中的變數。請在清單中輸入以逗號分隔的值。這些值會依照列出的順序與變數產生關聯。ArgumentList 的別名為 "Args"。
ArgumentList 中的值可以是實際值 (如 "1024") 或是區域變數的參考 (如 "$max")。
若要在命令中使用區域變數,請採用下列命令格式:
{param($<name1>[, $<name2>]...)<command-with-local-variables>} -ArgumentList <value | $local-variable>
"param" 關鍵字會列出命令中使用的區域變數。ArgumentList 參數會依照變數的列出順序提供變數值。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="true">Object[]</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="true (ByValue)" position="named">
<maml:name>InputObject</maml:name>
<maml:description>
<maml:para>指定命令的輸入。請輸入包含物件的變數,或輸入可取得物件的命令或運算式。
使用 InputObject 時,請在 ScriptBlock 參數的值中使用 $input 自動變數,以表示輸入物件。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">psobject</command:parameterValue>
</command:parameter>
</command:syntaxItem>
<command:syntaxItem>
<maml:name>Invoke-Command</maml:name>
<command:parameter required="true" variableLength="false" globbing="false" pipelineInput="false" position="2">
<maml:name>FilePath</maml:name>
<maml:description>
<maml:para>在一部或多部遠端電腦上執行指定的本機指令碼。請輸入指令碼的路徑和檔名,或經由管道將指令碼路徑輸出至 Invoke-Command。此指令碼必須存在於本機電腦或本機電腦可存取的目錄中。請使用 ArgumentList 參數指定指令碼中參數的值。
使用此參數時,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="true (ByPropertyName)" position="1">
<maml:name>ConnectionURI</maml:name>
<maml:description>
<maml:para>指定定義連線端點的統一資源識別項 (URI)。此 URI 必須是完整的 URI。
此字串的格式為:
<傳輸方式>://<電腦名稱>:<連接埠>/<應用程式名稱>
預設值為:
http://localhost:80/WSMAN
URI 中傳輸方式區段的有效值為 HTTP 和 HTTPS。如果未指定 ConnectionURI,就必須使用 UseSSL、ComputerName、Port 和 ApplicationName 參數指定 URI 值。
如果目的電腦將連線重新導向到不同的 URI,那麼除非您在命令中使用 AllowRedirection 參數,否則 Windows PowerShell 不會重新導向連線。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="true">Uri[]</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>AllowRedirection</maml:name>
<maml:description>
<maml:para>允許這個連線重新導向到其他 URI。
在使用 ConnectionURI 參數時,遠端目的地可能會傳回指示,以重新導向至不同的 URI。根據預設,Windows PowerShell 不會重新導向連線,但是您可以使用 AllowRedirection 參數允許它重新導向連線。
您也可以設定 $PSSessionOption 喜好設定變數的 MaximumConnectionRedirectionCount 屬性或 SessionOption 參數的 MaximumConnectionRedirectionCount 屬性值,藉此限制連線的重新導向次數。預設值為 5。如需詳細資訊,請參閱 SessionOption 參數的描述以及 New-PSSessionOption Cmdlet 的說明主題。</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>AsJob</maml:name>
<maml:description>
<maml:para>在遠端電腦將背景工作當做命令來執行。此參數可以用來執行需時甚久才能完成的命令。
使用 AsJob 時,此命令會傳回表示工作的物件,然後顯示命令提示字元。工作完成時,您可以繼續在工作階段中執行工作。若要管理工作,請使用各項 Job Cmdlet。若要取得工作結果,請使用 Receive-Job。
AsJob 參數的作用,與使用 Invoke-Command 從遠端執行 Start-Job 命令類似。然而,配搭 AsJob 時,即使工作是在遠端電腦執行,但仍是在本機電腦建立工作。此外,遠端工作的結果也會自動傳回到本機電腦。
如需 Windows PowerShell 背景工作的詳細資訊,請參閱 about_Jobs 和 about_Remote_Jobs。</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>Authentication</maml:name>
<maml:description>
<maml:para>指定用來驗證使用者認證的機制。有效值為 Default、Basic、Credssp、Digest、Kerberos、Negotiate 和 NegotiateWithImplicitCredential。預設值為 Default。
CredSSP 驗證僅適用於 Windows Vista、Windows Server 2008 和更新版的 Windows。
如需此參數之值的詳細資訊,請參閱 MSDN 中的 System.Management.Automation.Runspaces.AuthenticationMechanism 列舉說明。
警告:認證安全性服務提供者 (CredSSP) 驗證 (其中使用者的認證會傳送到遠端電腦) 是專為需要對一個以上的資源進行驗證的命令所設計,例如存取遠端網路共用。此機制會提高遠端操作的安全性風險。如果遠端電腦已經遭受危害,則傳遞給遠端電腦的認證可能會被用來控制網路工作階段。</maml:para>
</maml:description>
<command:parameterValueGroup>
<command:parameterValue required="false" variableLength="false">Default</command:parameterValue>
<command:parameterValue required="false" variableLength="false">Basic</command:parameterValue>
<command:parameterValue required="false" variableLength="false">Negotiate</command:parameterValue>
<command:parameterValue required="false" variableLength="false">NegotiateWithImplicitCredential</command:parameterValue>
<command:parameterValue required="false" variableLength="false">Credssp</command:parameterValue>
<command:parameterValue required="false" variableLength="false">Digest</command:parameterValue>
<command:parameterValue required="false" variableLength="false">Kerberos</command:parameterValue>
</command:parameterValueGroup>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="true (ByPropertyName)" position="named">
<maml:name>ConfigurationName</maml:name>
<maml:description>
<maml:para>指定用於新 PSSession 的工作階段設定。
請輸入工作階段設定的設定名稱或完整資源 URI。如果只指定設定名稱,則會在其前面加上下列結構描述 URI:http://schemas.microsoft.com/powershell。
工作階段的工作階段設定是位於遠端電腦。如果遠端電腦上沒有指定的工作階段設定,則命令會失敗。
預設值為本機電腦上的 $PSSessionConfigurationName 喜好設定變數的值。如果沒有設定此喜好設定變數,則預設值為 Microsoft.PowerShell。如需詳細資訊,請參閱 about_preference_variables。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">string</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="true (ByPropertyName)" position="named">
<maml:name>Credential</maml:name>
<maml:description>
<maml:para>指定具有執行此動作之權限的使用者帳戶。預設為目前使用者。
請輸入使用者名稱,例如 "User01" 或 "Domain01\User01",或是輸入含 PSCredential 物件的變數,例如 Get-Credential Cmdlet 所產生的物件。當您輸入使用者名稱時,會提示您輸入密碼。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">PSCredential</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>HideComputerName</maml:name>
<maml:description>
<maml:para>在輸出顯示中省略每一個物件的電腦名稱。根據預設,螢幕上會顯示產生物件的電腦名稱。
此參數只對輸出顯示有影響,而不會變更物件。</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>JobName</maml:name>
<maml:description>
<maml:para>指定好記的背景工作名稱。根據預設,工作會命名為 "Job<n>",其中 <n> 為序數。此參數只能與 AsJob 參數搭配使用。
如果您在命令中使用 JobName 參數,則會將命令當成工作來執行,且 Invoke-Command 會傳回工作物件,即使命令中不包含 AsJob 參數也是如此。
如需 Windows PowerShell 背景工作的詳細資訊,請參閱 about_Jobs。</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>SessionOption</maml:name>
<maml:description>
<maml:para>設定工作階段的進階選項。請輸入使用 New-PSSessionOption Cmdlet 所建立的 SessionOption 物件。
如果有設定 $PSSessionOption 喜好設定變數的值,它會決定選項的預設值。否則,工作階段會使用系統預設值。
如需工作階段選項 (包括預設值) 的描述,請參閱 New-PSSessionOption Cmdlet 的說明主題。如需 $PSSessionOption 喜好設定變數的詳細資訊,請參閱 about_Preference_Variables。
</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">PSSessionOption</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>ThrottleLimit</maml:name>
<maml:description>
<maml:para>指定可以建立以執行此命令之同時連線數目的上限。如果您省略這個參數或輸入 0 這個值,則會使用預設值 32。
節流閥限制只適用於目前的命令,並不適用於工作階段或電腦。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">int</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="false" position="named">
<maml:name>ArgumentList</maml:name>
<maml:description>
<maml:para>提供命令中的區域變數值。在遠端電腦執行命令之前,這些值會取代命令中的變數。請在清單中輸入以逗號分隔的值。這些值會依照列出的順序與變數產生關聯。ArgumentList 的別名為 "Args"。
ArgumentList 中的值可以是實際值 (如 "1024") 或是區域變數的參考 (如 "$max")。
若要在命令中使用區域變數,請採用下列命令格式:
{param($<name1>[, $<name2>]...)<command-with-local-variables>} -ArgumentList <value | $local-variable>
"param" 關鍵字會列出命令中使用的區域變數。ArgumentList 參數會依照變數的列出順序提供變數值。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="true">Object[]</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="true (ByValue)" position="named">
<maml:name>InputObject</maml:name>
<maml:description>
<maml:para>指定命令的輸入。請輸入包含物件的變數,或輸入可取得物件的命令或運算式。
使用 InputObject 時,請在 ScriptBlock 參數的值中使用 $input 自動變數,以表示輸入物件。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">psobject</command:parameterValue>
</command:parameter>
</command:syntaxItem>
<command:syntaxItem>
<maml:name>Invoke-Command</maml:name>
<command:parameter required="true" variableLength="false" globbing="false" pipelineInput="false" position="1">
<maml:name>ScriptBlock</maml:name>
<maml:description>
<maml:para>指定要執行的命令。請以大括號 ( { } ) 括住命令以建立指令碼區塊。此參數為必要項。
根據預設,命令中的所有變數都會在遠端電腦進行評估。若要在命令中加上區域變數,請使用 ArgumentList 參數。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">scriptblock</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="false" position="named">
<maml:name>ArgumentList</maml:name>
<maml:description>
<maml:para>提供命令中的區域變數值。在遠端電腦執行命令之前,這些值會取代命令中的變數。請在清單中輸入以逗號分隔的值。這些值會依照列出的順序與變數產生關聯。ArgumentList 的別名為 "Args"。
ArgumentList 中的值可以是實際值 (如 "1024") 或是區域變數的參考 (如 "$max")。
若要在命令中使用區域變數,請採用下列命令格式:
{param($<name1>[, $<name2>]...)<command-with-local-variables>} -ArgumentList <value | $local-variable>
"param" 關鍵字會列出命令中使用的區域變數。ArgumentList 參數會依照變數的列出順序提供變數值。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="true">Object[]</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="true (ByValue)" position="named">
<maml:name>InputObject</maml:name>
<maml:description>
<maml:para>指定命令的輸入。請輸入包含物件的變數,或輸入可取得物件的命令或運算式。
使用 InputObject 時,請在 ScriptBlock 參數的值中使用 $input 自動變數,以表示輸入物件。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">psobject</command:parameterValue>
</command:parameter>
</command:syntaxItem>
<command:syntaxItem>
<maml:name>Invoke-Command</maml:name>
<command:parameter required="true" variableLength="false" globbing="false" pipelineInput="false" position="2">
<maml:name>ScriptBlock</maml:name>
<maml:description>
<maml:para>指定要執行的命令。請以大括號 ( { } ) 括住命令以建立指令碼區塊。此參數為必要項。
根據預設,命令中的所有變數都會在遠端電腦進行評估。若要在命令中加上區域變數,請使用 ArgumentList 參數。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">scriptblock</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="true (ByPropertyName)" position="1">
<maml:name>Session</maml:name>
<maml:description>
<maml:para>在指定的 Windows PowerShell 工作階段 (PSSession) 中執行命令。請輸入包含 PSSession 的變數,或者輸入建立或取得 PSSession 的命令,例如 New-PSSession 或 Get-PSSession 命令。
建立 PSSession 時,Windows PowerShell 會建立與遠端電腦之間的固定連線。請使用 PSSession 來執行共用資料的一系列相關命令。若要執行單一命令或一系列相關命令,請使用 ComputerName 參數。
若要建立 PSSession,請使用 New-PSSession Cmdlet。如需詳細資訊,請參閱 about_PSSessions。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="true">PSSession[]</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>AsJob</maml:name>
<maml:description>
<maml:para>在遠端電腦將背景工作當做命令來執行。此參數可以用來執行需時甚久才能完成的命令。
使用 AsJob 時,此命令會傳回表示工作的物件,然後顯示命令提示字元。工作完成時,您可以繼續在工作階段中執行工作。若要管理工作,請使用各項 Job Cmdlet。若要取得工作結果,請使用 Receive-Job。
AsJob 參數的作用,與使用 Invoke-Command 從遠端執行 Start-Job 命令類似。然而,配搭 AsJob 時,即使工作是在遠端電腦執行,但仍是在本機電腦建立工作。此外,遠端工作的結果也會自動傳回到本機電腦。
如需 Windows PowerShell 背景工作的詳細資訊,請參閱 about_Jobs 和 about_Remote_Jobs。</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>HideComputerName</maml:name>
<maml:description>
<maml:para>在輸出顯示中省略每一個物件的電腦名稱。根據預設,螢幕上會顯示產生物件的電腦名稱。
此參數只對輸出顯示有影響,而不會變更物件。</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>JobName</maml:name>
<maml:description>
<maml:para>指定好記的背景工作名稱。根據預設,工作會命名為 "Job<n>",其中 <n> 為序數。此參數只能與 AsJob 參數搭配使用。
如果您在命令中使用 JobName 參數,則會將命令當成工作來執行,且 Invoke-Command 會傳回工作物件,即使命令中不包含 AsJob 參數也是如此。
如需 Windows PowerShell 背景工作的詳細資訊,請參閱 about_Jobs。</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>ThrottleLimit</maml:name>
<maml:description>
<maml:para>指定可以建立以執行此命令之同時連線數目的上限。如果您省略這個參數或輸入 0 這個值,則會使用預設值 32。
節流閥限制只適用於目前的命令,並不適用於工作階段或電腦。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">int</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="false" position="named">
<maml:name>ArgumentList</maml:name>
<maml:description>
<maml:para>提供命令中的區域變數值。在遠端電腦執行命令之前,這些值會取代命令中的變數。請在清單中輸入以逗號分隔的值。這些值會依照列出的順序與變數產生關聯。ArgumentList 的別名為 "Args"。
ArgumentList 中的值可以是實際值 (如 "1024") 或是區域變數的參考 (如 "$max")。
若要在命令中使用區域變數,請採用下列命令格式:
{param($<name1>[, $<name2>]...)<command-with-local-variables>} -ArgumentList <value | $local-variable>
"param" 關鍵字會列出命令中使用的區域變數。ArgumentList 參數會依照變數的列出順序提供變數值。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="true">Object[]</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="true (ByValue)" position="named">
<maml:name>InputObject</maml:name>
<maml:description>
<maml:para>指定命令的輸入。請輸入包含物件的變數,或輸入可取得物件的命令或運算式。
使用 InputObject 時,請在 ScriptBlock 參數的值中使用 $input 自動變數,以表示輸入物件。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">psobject</command:parameterValue>
</command:parameter>
</command:syntaxItem>
<command:syntaxItem>
<maml:name>Invoke-Command</maml:name>
<command:parameter required="true" variableLength="false" globbing="false" pipelineInput="false" position="2">
<maml:name>ScriptBlock</maml:name>
<maml:description>
<maml:para>指定要執行的命令。請以大括號 ( { } ) 括住命令以建立指令碼區塊。此參數為必要項。
根據預設,命令中的所有變數都會在遠端電腦進行評估。若要在命令中加上區域變數,請使用 ArgumentList 參數。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">scriptblock</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="true (ByPropertyName)" position="1">
<maml:name>ConnectionURI</maml:name>
<maml:description>
<maml:para>指定定義連線端點的統一資源識別項 (URI)。此 URI 必須是完整的 URI。
此字串的格式為:
<傳輸方式>://<電腦名稱>:<連接埠>/<應用程式名稱>
預設值為:
http://localhost:80/WSMAN
URI 中傳輸方式區段的有效值為 HTTP 和 HTTPS。如果未指定 ConnectionURI,就必須使用 UseSSL、ComputerName、Port 和 ApplicationName 參數指定 URI 值。
如果目的電腦將連線重新導向到不同的 URI,那麼除非您在命令中使用 AllowRedirection 參數,否則 Windows PowerShell 不會重新導向連線。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="true">Uri[]</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>AllowRedirection</maml:name>
<maml:description>
<maml:para>允許這個連線重新導向到其他 URI。
在使用 ConnectionURI 參數時,遠端目的地可能會傳回指示,以重新導向至不同的 URI。根據預設,Windows PowerShell 不會重新導向連線,但是您可以使用 AllowRedirection 參數允許它重新導向連線。
您也可以設定 $PSSessionOption 喜好設定變數的 MaximumConnectionRedirectionCount 屬性或 SessionOption 參數的 MaximumConnectionRedirectionCount 屬性值,藉此限制連線的重新導向次數。預設值為 5。如需詳細資訊,請參閱 SessionOption 參數的描述以及 New-PSSessionOption Cmdlet 的說明主題。</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>AsJob</maml:name>
<maml:description>
<maml:para>在遠端電腦將背景工作當做命令來執行。此參數可以用來執行需時甚久才能完成的命令。
使用 AsJob 時,此命令會傳回表示工作的物件,然後顯示命令提示字元。工作完成時,您可以繼續在工作階段中執行工作。若要管理工作,請使用各項 Job Cmdlet。若要取得工作結果,請使用 Receive-Job。
AsJob 參數的作用,與使用 Invoke-Command 從遠端執行 Start-Job 命令類似。然而,配搭 AsJob 時,即使工作是在遠端電腦執行,但仍是在本機電腦建立工作。此外,遠端工作的結果也會自動傳回到本機電腦。
如需 Windows PowerShell 背景工作的詳細資訊,請參閱 about_Jobs 和 about_Remote_Jobs。</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>Authentication</maml:name>
<maml:description>
<maml:para>指定用來驗證使用者認證的機制。有效值為 Default、Basic、Credssp、Digest、Kerberos、Negotiate 和 NegotiateWithImplicitCredential。預設值為 Default。
CredSSP 驗證僅適用於 Windows Vista、Windows Server 2008 和更新版的 Windows。
如需此參數之值的詳細資訊,請參閱 MSDN 中的 System.Management.Automation.Runspaces.AuthenticationMechanism 列舉說明。
警告:認證安全性服務提供者 (CredSSP) 驗證 (其中使用者的認證會傳送到遠端電腦) 是專為需要對一個以上的資源進行驗證的命令所設計,例如存取遠端網路共用。此機制會提高遠端操作的安全性風險。如果遠端電腦已經遭受危害,則傳遞給遠端電腦的認證可能會被用來控制網路工作階段。</maml:para>
</maml:description>
<command:parameterValueGroup>
<command:parameterValue required="false" variableLength="false">Default</command:parameterValue>
<command:parameterValue required="false" variableLength="false">Basic</command:parameterValue>
<command:parameterValue required="false" variableLength="false">Negotiate</command:parameterValue>
<command:parameterValue required="false" variableLength="false">NegotiateWithImplicitCredential</command:parameterValue>
<command:parameterValue required="false" variableLength="false">Credssp</command:parameterValue>
<command:parameterValue required="false" variableLength="false">Digest</command:parameterValue>
<command:parameterValue required="false" variableLength="false">Kerberos</command:parameterValue>
</command:parameterValueGroup>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>CertificateThumbprint</maml:name>
<maml:description>
<maml:para>對於具有執行此動作之權限的使用者帳戶,指定其數位公開金鑰憑證 (X509)。請輸入憑證的憑證指紋。
憑證係在進行用戶端憑證式驗證時使用。這些憑證只能對應到本機使用者帳戶,並不適用於網域帳戶。
若要取得憑證指紋,請在 Windows PowerShell 的 Cert: 磁碟機中使用 Get-Item 或 Get-ChildItem 命令。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">string</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="true (ByPropertyName)" position="named">
<maml:name>ConfigurationName</maml:name>
<maml:description>
<maml:para>指定用於新 PSSession 的工作階段設定。
請輸入工作階段設定的設定名稱或完整資源 URI。如果只指定設定名稱,則會在其前面加上下列結構描述 URI:http://schemas.microsoft.com/powershell。
工作階段的工作階段設定是位於遠端電腦。如果遠端電腦上沒有指定的工作階段設定,則命令會失敗。
預設值為本機電腦上的 $PSSessionConfigurationName 喜好設定變數的值。如果沒有設定此喜好設定變數,則預設值為 Microsoft.PowerShell。如需詳細資訊,請參閱 about_preference_variables。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">string</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="true (ByPropertyName)" position="named">
<maml:name>Credential</maml:name>
<maml:description>
<maml:para>指定具有執行此動作之權限的使用者帳戶。預設為目前使用者。
請輸入使用者名稱,例如 "User01" 或 "Domain01\User01",或是輸入含 PSCredential 物件的變數,例如 Get-Credential Cmdlet 所產生的物件。當您輸入使用者名稱時,會提示您輸入密碼。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">PSCredential</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>HideComputerName</maml:name>
<maml:description>
<maml:para>在輸出顯示中省略每一個物件的電腦名稱。根據預設,螢幕上會顯示產生物件的電腦名稱。
此參數只對輸出顯示有影響,而不會變更物件。</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>JobName</maml:name>
<maml:description>
<maml:para>指定好記的背景工作名稱。根據預設,工作會命名為 "Job<n>",其中 <n> 為序數。此參數只能與 AsJob 參數搭配使用。
如果您在命令中使用 JobName 參數,則會將命令當成工作來執行,且 Invoke-Command 會傳回工作物件,即使命令中不包含 AsJob 參數也是如此。
如需 Windows PowerShell 背景工作的詳細資訊,請參閱 about_Jobs。</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>SessionOption</maml:name>
<maml:description>
<maml:para>設定工作階段的進階選項。請輸入使用 New-PSSessionOption Cmdlet 所建立的 SessionOption 物件。
如果有設定 $PSSessionOption 喜好設定變數的值,它會決定選項的預設值。否則,工作階段會使用系統預設值。
如需工作階段選項 (包括預設值) 的描述,請參閱 New-PSSessionOption Cmdlet 的說明主題。如需 $PSSessionOption 喜好設定變數的詳細資訊,請參閱 about_Preference_Variables。
</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">PSSessionOption</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>ThrottleLimit</maml:name>
<maml:description>
<maml:para>指定可以建立以執行此命令之同時連線數目的上限。如果您省略這個參數或輸入 0 這個值,則會使用預設值 32。
節流閥限制只適用於目前的命令,並不適用於工作階段或電腦。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">int</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="false" position="named">
<maml:name>ArgumentList</maml:name>
<maml:description>
<maml:para>提供命令中的區域變數值。在遠端電腦執行命令之前,這些值會取代命令中的變數。請在清單中輸入以逗號分隔的值。這些值會依照列出的順序與變數產生關聯。ArgumentList 的別名為 "Args"。
ArgumentList 中的值可以是實際值 (如 "1024") 或是區域變數的參考 (如 "$max")。
若要在命令中使用區域變數,請採用下列命令格式:
{param($<name1>[, $<name2>]...)<command-with-local-variables>} -ArgumentList <value | $local-variable>
"param" 關鍵字會列出命令中使用的區域變數。ArgumentList 參數會依照變數的列出順序提供變數值。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="true">Object[]</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="true (ByValue)" position="named">
<maml:name>InputObject</maml:name>
<maml:description>
<maml:para>指定命令的輸入。請輸入包含物件的變數,或輸入可取得物件的命令或運算式。
使用 InputObject 時,請在 ScriptBlock 參數的值中使用 $input 自動變數,以表示輸入物件。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">psobject</command:parameterValue>
</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>AllowRedirection</maml:name>
<maml:description>
<maml:para>允許這個連線重新導向到其他 URI。
在使用 ConnectionURI 參數時,遠端目的地可能會傳回指示,以重新導向至不同的 URI。根據預設,Windows PowerShell 不會重新導向連線,但是您可以使用 AllowRedirection 參數允許它重新導向連線。
您也可以設定 $PSSessionOption 喜好設定變數的 MaximumConnectionRedirectionCount 屬性或 SessionOption 參數的 MaximumConnectionRedirectionCount 屬性值,藉此限制連線的重新導向次數。預設值為 5。如需詳細資訊,請參閱 SessionOption 參數的描述以及 New-PSSessionOption 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="true (ByPropertyName)" position="named">
<maml:name>ApplicationName</maml:name>
<maml:description>
<maml:para>指定連線 URI 的應用程式名稱區段。當您沒有在命令中使用 ConnectionURI 參數時,可以使用此參數指定應用程式名稱。
預設值為本機電腦上的 $PSSessionApplicationName 喜好設定變數的值。如果沒有定義此喜好設定變數,則預設值為 WSMAN。這個值適合大部分使用情況。如需詳細資訊,請參閱 about_Preference_Variables。
WinRM 服務會使用應用程式名稱來選取要服務連線要求的接聽程式。這個參數的值必須符合遠端電腦上接聽程式的 URLPrefix 屬性值。</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>WSMAN</dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="false" position="named">
<maml:name>ArgumentList</maml:name>
<maml:description>
<maml:para>提供命令中的區域變數值。在遠端電腦執行命令之前,這些值會取代命令中的變數。請在清單中輸入以逗號分隔的值。這些值會依照列出的順序與變數產生關聯。ArgumentList 的別名為 "Args"。
ArgumentList 中的值可以是實際值 (如 "1024") 或是區域變數的參考 (如 "$max")。
若要在命令中使用區域變數,請採用下列命令格式:
{param($<name1>[, $<name2>]...)<command-with-local-variables>} -ArgumentList <value | $local-variable>
"param" 關鍵字會列出命令中使用的區域變數。ArgumentList 參數會依照變數的列出順序提供變數值。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="true">Object[]</command:parameterValue>
<dev:type>
<maml:name>Object[]</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>AsJob</maml:name>
<maml:description>
<maml:para>在遠端電腦將背景工作當做命令來執行。此參數可以用來執行需時甚久才能完成的命令。
使用 AsJob 時,此命令會傳回表示工作的物件,然後顯示命令提示字元。工作完成時,您可以繼續在工作階段中執行工作。若要管理工作,請使用各項 Job Cmdlet。若要取得工作結果,請使用 Receive-Job。
AsJob 參數的作用,與使用 Invoke-Command 從遠端執行 Start-Job 命令類似。然而,配搭 AsJob 時,即使工作是在遠端電腦執行,但仍是在本機電腦建立工作。此外,遠端工作的結果也會自動傳回到本機電腦。
如需 Windows PowerShell 背景工作的詳細資訊,請參閱 about_Jobs 和 about_Remote_Jobs。</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>Authentication</maml:name>
<maml:description>
<maml:para>指定用來驗證使用者認證的機制。有效值為 Default、Basic、Credssp、Digest、Kerberos、Negotiate 和 NegotiateWithImplicitCredential。預設值為 Default。
CredSSP 驗證僅適用於 Windows Vista、Windows Server 2008 和更新版的 Windows。
如需此參數之值的詳細資訊,請參閱 MSDN 中的 System.Management.Automation.Runspaces.AuthenticationMechanism 列舉說明。
警告:認證安全性服務提供者 (CredSSP) 驗證 (其中使用者的認證會傳送到遠端電腦) 是專為需要對一個以上的資源進行驗證的命令所設計,例如存取遠端網路共用。此機制會提高遠端操作的安全性風險。如果遠端電腦已經遭受危害,則傳遞給遠端電腦的認證可能會被用來控制網路工作階段。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">AuthenticationMechanism</command:parameterValue>
<dev:type>
<maml:name>AuthenticationMechanism</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>Default</dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>CertificateThumbprint</maml:name>
<maml:description>
<maml:para>對於具有執行此動作之權限的使用者帳戶,指定其數位公開金鑰憑證 (X509)。請輸入憑證的憑證指紋。
憑證係在進行用戶端憑證式驗證時使用。這些憑證只能對應到本機使用者帳戶,並不適用於網域帳戶。
若要取得憑證指紋,請在 Windows PowerShell 的 Cert: 磁碟機中使用 Get-Item 或 Get-ChildItem 命令。</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="true (ByPropertyName)" position="1">
<maml:name>ComputerName</maml:name>
<maml:description>
<maml:para>指定執行命令的電腦。預設為本機電腦。
使用 ComputerName 參數時,Windows PowerShell 會建立暫時連線,這個連線在執行完指定的命令之後便會關閉。如果您需要固定連線,請使用 Session 參數。
請在清單中以逗號分隔的方式,輸入一部或多部電腦的 NETBIOS 名稱、IP 位址或完整網域名稱。若要指定本機電腦,請輸入電腦名稱、"localhost" 或點 (.)。
若要在 ComputerName 參數的值中使用 IP 位址,命令必須包含 Credential 參數。而且,該電腦必須設定成 HTTPS 傳輸,或者遠端電腦的 IP 位址必須包含在本機電腦的 WinRM TrustedHosts 清單中。如需將電腦名稱新增到 TrustedHosts 清單的指示,請參閱 about_Remote_Troubleshooting 中的<如何將電腦新增到信任的主機清單>。
注意:在 Windows Vista 和更新版的 Windows 上,若要在 ComputerName 參數值中包含本機電腦,您必須以 [以系統管理員身分執行] 選項開啟 Windows PowerShell。</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="true (ByPropertyName)" position="named">
<maml:name>ConfigurationName</maml:name>
<maml:description>
<maml:para>指定用於新 PSSession 的工作階段設定。
請輸入工作階段設定的設定名稱或完整資源 URI。如果只指定設定名稱,則會在其前面加上下列結構描述 URI:http://schemas.microsoft.com/powershell。
工作階段的工作階段設定是位於遠端電腦。如果遠端電腦上沒有指定的工作階段設定,則命令會失敗。
預設值為本機電腦上的 $PSSessionConfigurationName 喜好設定變數的值。如果沒有設定此喜好設定變數,則預設值為 Microsoft.PowerShell。如需詳細資訊,請參閱 about_preference_variables。</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>http://Schemas.Microsoft.com/PowerShell/Microsoft.PowerShell</dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="true (ByPropertyName)" position="1">
<maml:name>ConnectionURI</maml:name>
<maml:description>
<maml:para>指定定義連線端點的統一資源識別項 (URI)。此 URI 必須是完整的 URI。
此字串的格式為:
<傳輸方式>://<電腦名稱>:<連接埠>/<應用程式名稱>
預設值為:
http://localhost:80/WSMAN
URI 中傳輸方式區段的有效值為 HTTP 和 HTTPS。如果未指定 ConnectionURI,就必須使用 UseSSL、ComputerName、Port 和 ApplicationName 參數指定 URI 值。
如果目的電腦將連線重新導向到不同的 URI,那麼除非您在命令中使用 AllowRedirection 參數,否則 Windows PowerShell 不會重新導向連線。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="true">Uri[]</command:parameterValue>
<dev:type>
<maml:name>Uri[]</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>http://localhost:80/wsman</dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="true (ByPropertyName)" position="named">
<maml:name>Credential</maml:name>
<maml:description>
<maml:para>指定具有執行此動作之權限的使用者帳戶。預設為目前使用者。
請輸入使用者名稱,例如 "User01" 或 "Domain01\User01",或是輸入含 PSCredential 物件的變數,例如 Get-Credential Cmdlet 所產生的物件。當您輸入使用者名稱時,會提示您輸入密碼。</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:parameter required="true" variableLength="false" globbing="false" pipelineInput="false" position="2">
<maml:name>FilePath</maml:name>
<maml:description>
<maml:para>在一部或多部遠端電腦上執行指定的本機指令碼。請輸入指令碼的路徑和檔名,或經由管道將指令碼路徑輸出至 Invoke-Command。此指令碼必須存在於本機電腦或本機電腦可存取的目錄中。請使用 ArgumentList 參數指定指令碼中參數的值。
使用此參數時,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="false" globbing="false" pipelineInput="false" position="named">
<maml:name>HideComputerName</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></dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="true (ByValue)" position="named">
<maml:name>InputObject</maml:name>
<maml:description>
<maml:para>指定命令的輸入。請輸入包含物件的變數,或輸入可取得物件的命令或運算式。
使用 InputObject 時,請在 ScriptBlock 參數的值中使用 $input 自動變數,以表示輸入物件。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">psobject</command:parameterValue>
<dev:type>
<maml:name>psobject</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>JobName</maml:name>
<maml:description>
<maml:para>指定好記的背景工作名稱。根據預設,工作會命名為 "Job<n>",其中 <n> 為序數。此參數只能與 AsJob 參數搭配使用。
如果您在命令中使用 JobName 參數,則會將命令當成工作來執行,且 Invoke-Command 會傳回工作物件,即使命令中不包含 AsJob 參數也是如此。
如需 Windows PowerShell 背景工作的詳細資訊,請參閱 about_Jobs。</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>Job<n></dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>Port</maml:name>
<maml:description>
<maml:para>指定遠端電腦上要供此命令使用的網路連接埠。預設為連接埠 80 (HTTP 連接埠)。
使用其他連接埠之前,必須先於遠端電腦上設定 WinRM 接聽程式,以接聽該連接埠。若要設定接聽程式,請在 Windows PowerShell 提示字元中輸入下列兩個命令:
remove-item -path wsman:\Localhost\listener\listener* -recurse
new-item -path wsman:\Localhost\listener -Transport http -Address * -port <連接埠號碼>
除非必要,否則請勿使用 Port 參數。命令中的 Port 設定適用於執行命令的所有電腦或工作階段。其他連接埠設定可能會導致無法在所有電腦上執行命令。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">int</command:parameterValue>
<dev:type>
<maml:name>int</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue></dev:defaultValue>
</command:parameter>
<command:parameter required="true" variableLength="false" globbing="false" pipelineInput="false" position="1">
<maml:name>ScriptBlock</maml:name>
<maml:description>
<maml:para>指定要執行的命令。請以大括號 ( { } ) 括住命令以建立指令碼區塊。此參數為必要項。
根據預設,命令中的所有變數都會在遠端電腦進行評估。若要在命令中加上區域變數,請使用 ArgumentList 參數。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">scriptblock</command:parameterValue>
<dev:type>
<maml:name>scriptblock</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue></dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="true (ByPropertyName)" position="1">
<maml:name>Session</maml:name>
<maml:description>
<maml:para>在指定的 Windows PowerShell 工作階段 (PSSession) 中執行命令。請輸入包含 PSSession 的變數,或者輸入建立或取得 PSSession 的命令,例如 New-PSSession 或 Get-PSSession 命令。
建立 PSSession 時,Windows PowerShell 會建立與遠端電腦之間的固定連線。請使用 PSSession 來執行共用資料的一系列相關命令。若要執行單一命令或一系列相關命令,請使用 ComputerName 參數。
若要建立 PSSession,請使用 New-PSSession Cmdlet。如需詳細資訊,請參閱 about_PSSessions。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="true">PSSession[]</command:parameterValue>
<dev:type>
<maml:name>PSSession[]</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>SessionOption</maml:name>
<maml:description>
<maml:para>設定工作階段的進階選項。請輸入使用 New-PSSessionOption Cmdlet 所建立的 SessionOption 物件。
如果有設定 $PSSessionOption 喜好設定變數的值,它會決定選項的預設值。否則,工作階段會使用系統預設值。
如需工作階段選項 (包括預設值) 的描述,請參閱 New-PSSessionOption Cmdlet 的說明主題。如需 $PSSessionOption 喜好設定變數的詳細資訊,請參閱 about_Preference_Variables。
</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">PSSessionOption</command:parameterValue>
<dev:type>
<maml:name>PSSessionOption</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>ThrottleLimit</maml:name>
<maml:description>
<maml:para>指定可以建立以執行此命令之同時連線數目的上限。如果您省略這個參數或輸入 0 這個值,則會使用預設值 32。
節流閥限制只適用於目前的命令,並不適用於工作階段或電腦。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">int</command:parameterValue>
<dev:type>
<maml:name>int</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>32</dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>UseSSL</maml:name>
<maml:description>
<maml:para>使用安全通訊端層 (SSL) 通訊協定建立與遠端電腦的連線。預設不會使用 SSL,
因為 WS-Management 會將所有透過網路傳輸的 Windows PowerShell 內容加密。使用 UseSSL 時,便會透過 HTTPS (而非 HTTP) 傳送資料,提供多一層防護。
如果使用此參數,但是供命令使用的連接埠無法使用 SSL,則命令會失敗。</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:parameters>
<!-- Input - Output section-->
<command:inputTypes>
<command:inputType>
<dev:type>
<maml:name>System.Management.Automation.ScriptBlock</maml:name>
<maml:uri />
<maml:description />
</dev:type>
<maml:description>
<maml:para>
<!-- description -->
您可以經由管道將指令碼區塊中的命令輸出至 Invoke-Command。請使用 $input 自動變數表示命令中的輸入物件。
</maml:para>
</maml:description>
</command:inputType>
</command:inputTypes>
<command:returnValues>
<command:returnValue>
<dev:type>
<maml:name>System.Management.Automation.PSRemotingJob 或叫用命令的輸出
</maml:name>
<maml:uri />
<maml:description />
</dev:type>
<maml:description>
<maml:para>
<!-- description -->
使用 AsJob 參數時,Invoke-Command 會傳回工作物件。否則,它會傳回叫用命令的輸出 (ScriptBlock 參數的值)。
</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 Vista 與較新的 Windows 版本,若要使用 Invoke-Command 的 ComputerName 參數在本機電腦執行命令,必須以 [以系統管理員身分執行] 選項開啟 Windows PowerShell。
-- 在多部電腦執行命令時,Windows PowerShell 會依照電腦出現在清單中的順序,連線到這些電腦。不過,命令輸出會依遠端電腦所擷取的命令順序來顯示,而可能不同。
-- Invoke-Command 執行之命令所產生的錯誤包含在命令結果中。本機命令中的終止錯誤在遠端命令中會被視為非終止錯誤。此策略可確保某一台電腦發生終止錯誤時,不會在執行命令的所有電腦終止該命令。即使遠端命令是在單一電腦執行,也會採用這種做法。
-- 如果遠端電腦不在本機電腦信任的網域中,電腦可能無法驗證使用者的認證。若要在 WS-Management 中將遠端電腦新增至「信任的主機」清單,請在 WSMAN 提供者中使用下列命令 (其中 <遠端電腦名稱> 是遠端電腦的名稱):
set-item -path wsman:\Localhost\Client\TrustedHosts -value <遠端電腦名稱>。
</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>
invoke-command -filepath c:\scripts\test.ps1 -computerName Server01
Disks: C:, D:, E:
Status: Warning, Normal, Normal
</dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個命令會在 Server01 電腦上執行 Test.ps1 指令碼。
此命令會使用 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>
invoke-command -computername server01 -credential domain01\user01 -scriptblock {get-culture} </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個命令會在 Server01 遠端電腦執行 Get-Culture 命令。
它會使用 ComputerName 參數指定電腦名稱,並使用 Credential 參數在 "Domain01\User01" (具有執行命令之權限的使用者) 的安全內容中執行命令。此外,它還會使用 ScriptBlock 參數指定要在遠端電腦執行的命令。
Windows PowerShell 會顯示對話方塊,要求 User01 帳戶的密碼與驗證方法,以示回應。接著,它會在 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>
$s = new-pssession -computername server02 -credential domain01\user01
C:\PS> invoke-command -session $s -scriptblock {get-culture} </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>此範例會在 Server02 遠端電腦的工作階段 (固定連線) 中執行相同的 "Get-Culture" 命令。通常只有在遠端電腦執行一系列命令時,您才會建立工作階段。
第一個命令會使用 New-PSSession Cmdlet,在 Server02 遠端電腦建立工作階段,然後將工作階段儲存在 $s 變數中。
第二個命令會使用 Invoke-Command Cmdlet,在 Server02 執行 Get-Culture 命令,並使用 Session 參數指定儲存在 $s 變數中的工作階段。
Windows PowerShell 會在 Server02 電腦的工作階段中執行命令,以示回應。</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>
invoke-command -computername Server02 -scriptblock {$p = get-process powershell}
C:\PS> invoke-command -computername Server02 -scriptblock {$p.virtualmemorysize}
C:\PS>
C:\PS> $s = new-pssession -computername Server02
C:\PS> invoke-command -session $s -scriptblock {$p = get-process powershell}
C:\PS> invoke-command -session $s -scriptblock {$p.virtualmemorysize}
17930240 </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個範例會比較使用 Invoke-Command 之 ComputerName 和 Session 參數的效果。其中顯示如何使用工作階段,執行共用相同資料的一系列命令。
前兩個命令會使用 Invoke-Command 的 ComputerName 參數,在 Server02 遠端電腦執行命令。第一個命令會使用 Get-Process 命令取得遠端電腦的 PowerShell 處理序,並將它儲存在 $p 變數中。第二個命令則會取得 PowerShell 處理序的 VirtualMemorySize 屬性值。
第一個命令執行成功,但第二個命令執行失敗,因為當您使用 ComputerName 參數時,Windows PowerShell 建立的連線只會執行命令,然後再於命令完成後關閉該連線。$p 變數是在一個連線中建立,但是在針對第二個命令所建立的連線中,這個變數並不存在。
解決這個問題的方法是在遠端電腦上建立工作階段 (固定連線),並在相同的工作階段中執行這兩個相關命令。
第三個命令會使用 New-PSSession Cmdlet,在 Server02 電腦建立工作階段,然後將工作階段儲存在 $s 變數中。第四和第五個命令會重複第一個集合中使用的一系列命令,但是這次 Invoke-Command 命令會使用 Session 參數,在相同的工作階段中執行這兩個命令。
這次由於兩個命令是在相同的工作階段中執行,因此命令會執行成功,而且 $p 值在 $s 工作階段中將持續作用,以供日後使用。</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>
$command = { get-eventlog -log "windows powershell" | where {$_.message -like "*certificate*"} }
C:\PS> invoke-command -computername S1, S2 -scriptblock $command </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>在這個範例中,會示範如何輸入儲存在本機變數中的命令。
當整個命令都儲存在本機變數時,您可以指定該變數做為 ScriptBlock 參數的值。您不需要使用 "param" 關鍵字或 ArgumentList 變數來提交本機變數的值。
第一個命令會將 Get-Eventlog 命令儲存在 $command 變數中。這個命令的格式會做為指令碼區塊。
第二個命令會使用 Invoke-Command Cmdlet,在 S1 和 S2 遠端電腦執行 $command 中的命令。</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>
invoke-command -computername server01, server02, TST-0143, localhost -configurationname MySession.PowerShell -scriptblock {get-eventlog "windows powershell"} </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>在這個範例中,會示範如何使用 Invoke-Command Cmdlet 在多部電腦執行單一命令。
此命令會使用 ComputerName 參數來指定這些電腦。這些電腦的名稱會以逗號分隔清單來呈現。電腦清單包括 "localhost" 值,代表本機電腦。
這個命令會使用 ConfigurationName 參數來指定 Windows PowerShell 的其他工作階段設定,並使用 ScriptBlock 參數來指定命令。
在這個範例中,指令碼區塊中的命令會取得每一部遠端電腦上 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>
-------------------------- 範例 7 --------------------------
</maml:title>
<maml:introduction>
<maml:para>C:\PS></maml:para>
</maml:introduction>
<dev:code>
$version = invoke-command -computername (get-content machines.txt) -scriptblock {(get-host).version} </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個命令會取得在 200 部遠端電腦執行之 Windows PowerShell 主機的版本。
由於執行的命令只有一個,因此不需要建立與每一台電腦的固定連線 (工作階段)。所以,此命令會使用 ComputerName 參數來指定電腦。
這個命令會使用 Invoke-Command Cmdlet 來執行 Get-Host 命令,並使用點標記法取得 Windows PowerShell 主機的 Version 屬性。
為了指定電腦,它會使用 Get-Content Cmdlet 取得 Machine.txt 檔案 (電腦名稱的檔案) 的內容。
這些命令會同步執行 (一次執行一個)。當命令執行完畢後,所有電腦的命令輸出都會儲存在 $version 變數中。輸出中包括產生這些資料的來源電腦名稱。</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>
-------------------------- 範例 8 --------------------------
</maml:title>
<maml:introduction>
<maml:para>C:\PS></maml:para>
</maml:introduction>
<dev:code>
$s = new-pssession -computername Server01, Server02
C:\PS> invoke-command -session $s -scriptblock {get-eventlog system} -AsJob
Id Name State HasMoreData Location Command
--- ---- ----- ----- ----------- -------- -------
1 Job1 Running True Server01,Server02 get-eventlog system
C:\PS> $j = Get-Job
C:\PS> $j | format-list -property *
HasMoreData : True
StatusMessage :
Location : Server01,Server02
Command : get-eventlog system
JobStateInfo : Running
Finished : System.Threading.ManualResetEvent
InstanceId : e124bb59-8cb2-498b-a0d2-2e07d4e030ca
Id : 1
Name : Job1
ChildJobs : {Job2, Job3}
Output : {}
Error : {}
Progress : {}
Verbose : {}
Debug : {}
Warning : {}
StateChanged :
C:\PS> $results = $j | Receive-Job </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這些命令會在兩部遠端電腦上執行背景工作。因為 Invoke-Command 命令會使用 AsJob 參數,所以雖然這些命令在遠端電腦上執行,不過工作實際上位於本機電腦,而且結果會傳送至本機電腦。
第一個命令會使用 New-PSSession Cmdlet,在 Server01 和 Server02 遠端電腦建立工作階段。
第二個命令會使用 Invoke-Command Cmdlet,在每個工作階段中執行背景工作。這個命令會使用 AsJob 參數,將命令當做背景工作來執行。它會傳回工作物件,其中包含兩個子工作物件,分別表示兩部遠端電腦執行的每一項工作。
第三個命令會使用 Get-Job 命令將工作物件儲存在 $j 變數中。
第四個命令會使用管線運算子 (|),將 $j 變數的值傳送至 Format-List Cmdlet,並由後者將此工作的所有屬性顯示在清單中。
第五個命令會取得工作的結果。它會經由管道,將 $j 中的工作物件輸出至 Receive-Job Cmdlet,並將結果儲存在 $results 變數中。</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>
-------------------------- 範例 9 --------------------------
</maml:title>
<maml:introduction>
<maml:para>C:\PS></maml:para>
</maml:introduction>
<dev:code>
$MWFO-LOg = Microsoft-Windows-Forwarding/Operational
C:\PS> invoke-command -computername server01 -scriptblock {param($log, $num) get-eventlog -logname $log -newest $num} -ArgumentList $MWFO-log, 10 </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>在這個範例中,會示範如何將本機變數的值加入在遠端電腦執行的命令中。
第一個命令會將 Microsoft-Windows-Forwarding/Operational 事件記錄檔的名稱儲存在 $MWFO-Log 變數中。
第二個命令會使用 Invoke-Command Cmdlet在 Server01 遠端電腦執行 Get-EventLog 命令,以便從 Server01 的 Microsoft-Windows-Forwarding/Operational 事件記錄檔中取得最新的 10 個事件。
這個命令會使用 "param" 關鍵字建立 $log 和 $num 兩個變數,做為 Get-EventLog 命令中的預留位置使用。這些預留位置具有任意名稱,不必符合提供其值之本機變數的名稱。
ArgumentList 參數的值示範兩種在引數清單中指定值的不同方法。$log 預留位置的值是在第一個命令中定義的 $MFWO-Log 變數。$num 變數的值是 10。
命令在傳送到遠端電腦之前,這些變數都會被取代成指定的值。
</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>
-------------------------- 範例 10 --------------------------
</maml:title>
<maml:introduction>
<maml:para>C:\PS></maml:para>
</maml:introduction>
<dev:code>
invoke-command -computername S1, S2 -scriptblock {get-process powershell}
PSComputerName Handles NPM(K) PM(K) WS(K) VM(M) CPU(s) Id ProcessName
-------------- ------- ------ ----- ----- ----- ------ -- -----------
S1 575 15 45100 40988 200 4.68 1392 powershell
S2 777 14 35100 30988 150 3.68 67 powershell
C:\PS> invoke-command -computername S1, S2 -scriptblock {get-process powershell} -HideComputerName
Handles NPM(K) PM(K) WS(K) VM(M) CPU(s) Id ProcessName
------- ------ ----- ----- ----- ------ -- -----------
575 15 45100 40988 200 4.68 1392 powershell
777 14 35100 30988 150 3.68 67 powershell </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>在這個範例中,會顯示使用 Invoke-Command 之 HideComputerName 參數的效果。
前兩個命令會使用 Invoke-Command Cmdlet 針對 PowerShell 處理序執行 Get-Process 命令。第一個命令的輸出包括 PsComputerName 屬性,而該屬性包含執行命令的電腦名稱。第二個命令會使用 HideComputerName 參數,其輸出並不包括 PsComputerName 一欄。
使用 HideComputerName 參數並不會變更物件。您仍然可以使用各項 Format Cmdlet,顯示所有受影響之物件的 PsComputerName 屬性。</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>
-------------------------- 範例 11 --------------------------
</maml:title>
<maml:introduction>
<maml:para>C:\PS></maml:para>
</maml:introduction>
<dev:code>
invoke-command -comp (get-content servers.txt) -filepath c:\scripts\sample.ps1 -argumentlist Process, Service </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個範例會使用 Invoke-Command Cmdlet 在 Servers.txt 檔案列出的所有電腦執行 Sample.ps1 指令碼,並使用 FilePath 參數指定程式碼檔案。即使遠端電腦無法存取指令碼檔案,這個命令也可以讓您在遠端電腦執行指令碼。
提交命令時,便會將 Sample.ps1 檔案的內容複製到指令碼區塊中,而且此指令碼區塊會在每一部遠端電腦執行。這個程序相當於使用 ScriptBlock 參數提交指令碼的內容。</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>
-------------------------- 範例 12 --------------------------
</maml:title>
<maml:introduction>
<maml:para>C:\PS></maml:para>
</maml:introduction>
<dev:code>
$LiveCred = Get-Credential
C:\PS> Invoke-Command -ConfigurationName Microsoft.Exchange `
-ConnectionUri https://ps.exchangelabs.com/powershell `
-Credential $LiveCred -Authentication Basic `
-scriptblock {Invoke-Command {Set-Mailbox dan -DisplayName "Dan Park"} </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>在這個範例中,會示範如何在 URI (網際網路位址) 所識別的遠端電腦執行命令。此特定範例會在遠端 Exchange 伺服器上執行 Set-Mailbox 命令。命令中的倒引號字元 (`) 是 Windows PowerShell 接續字元。
第一個命令會使用 Get-Credential Cmdlet,將 Windows Live ID 認證儲存在 $LiveCred 變數中。當認證對話方塊出現時,請輸入 Windows Live ID 認證。
第二個命令會使用 Invoke-Command Cmdlet 來執行 Set-Mailbox 命令,並使用 ConfigurationName 參數指定命令應該在使用 Microsoft.Exchange 工作階段設定的工作階段中執行、ConnectionURI 參數指定 Exchange 伺服器端點的 URL、
Credential 參數指定儲存在 $LiveCred 變數中的 Windows Live 認證、AuthenticationMechanism 參數指定使用基本驗證,以及 ScriptBlock 參數指定包含命令的指令碼區塊。</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>
-------------------------- 範例 13 --------------------------
</maml:title>
<maml:introduction>
<maml:para>C:\PS></maml:para>
</maml:introduction>
<dev:code>
$max = New-PSSessionOption -MaximumRedirection 1
C:\PS> Invoke-Command -ConnectionUri https://ps.exchangelabs.com/powershell `
-scriptblock {Invoke-Command {Get-Mailbox dan} `
-AllowRedirection -SessionOption $max </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個命令會示範如何使用 AllowRedirection 和 SessionOption 參數,在遠端命令中管理 URI 重新導向。
第一個命令會使用 New-PSSessionOption Cmdlet 來建立儲存在 $max 變數中的 PSSessionOpption 物件。此命令會使用 MaximumRedirection 參數,將 PSSessionOption 物件的 MaximumConnectionRedirectionCount 屬性設定為 1。
第二個命令會使用 Invoke-Command Cmdlet,在執行 Microsoft Exchange Server 的遠端伺服器上執行 Get-Mailbox 命令。此外,這個命令會使用 AllowRedirection 參數提供明確權限,以便將連線重新導向到其他端點。它也會使用 SessionOption 參數來指定 $max 變數中的工作階段物件。
因此,如果 ConnectionURI 參數指定的遠端電腦傳回重新導向訊息,Windows PowerShell 會重新導向連線。但是如果新的目的地傳回其他重新導向訊息,便會超過重新導向計數值 1,而導致 Invoke-Command 傳回非終止錯誤。</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>
-------------------------- 範例 14 --------------------------
</maml:title>
<maml:introduction>
<maml:para>C:\PS></maml:para>
</maml:introduction>
<dev:code>
$so = New-PSSessionOption -SkipCACheck
PS C:\> invoke-command $s { get-hotfix } -SessionOption $so -credential server01\user01 </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>在這個範例中,會示範如何建立及使用 SessionOption 參數。
第一個命令會使用 New-PSSessionOption Cmdlet 建立工作階段選項,並會將產生的 SessionOption 物件儲存在 $so 參數中。
第二個命令會使用 Invoke-Command Cmdlet 從遠端執行 Get-Hotfix 命令。SessionOption 參數的值是 $so 變數中的 SessionOption 物件。</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>
-------------------------- 範例 15 --------------------------
</maml:title>
<maml:introduction>
<maml:para>C:\PS></maml:para>
</maml:introduction>
<dev:code>
enable-wsmanCredSSP -delegate server02
C:\PS> connect-wsman Server02
C:\PS> set-item wsman:\server02*\service\auth\credSSP -value $true
C:\PS> $s = new-pssession server02
C:\PS> invoke-command -session $s -script {get-item \\Net03\Scripts\LogFiles.ps1} -authentication credssp -credential domain01\admin01 </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個範例會示範如何從遠端工作階段內部存取網路共用。
此命令要求本機電腦的用戶端設定以及遠端電腦的服務設定都必須啟用 CredSSP 委派。若要執行這個範例中的命令,您必須是本機電腦和遠端電腦上 Administrators 群組的成員。
第一個命令會使用 Enable-WSManCredSSP Cmdlet 來啟用從 Server01 本機電腦到 Server02 遠端電腦的 CredSSP 委派。這個命令會設定本機電腦的 CredSSP 用戶端設定。
第二個命令會使用 Connect-WSman Cmdlet 來連線到 Server02 電腦。這個動作會將 Server02 電腦的節點新增至本機電腦的 WSMan: 磁碟機,讓您檢視和變更 Server02 電腦的 WS-Management 設定。
第三個命令會使用 Set-Item Cmdlet,將 Server02 電腦之 Service 節點中的 CredSSP 項目值變更為 True。這個動作會在遠端電腦的服務設定中啟用 CredSSP。
第四個命令會使用 New-PSSession Cmdlet,在 Server02 電腦上建立 PSSession,並將這個 PSSession 儲存在 $s 變數中。
第五個命令會使用 Invoke-Command Cmdlet,在 $s 的工作階段中執行 Get-Item 命令,以便從 Net03\Scripts 網路共用取得指令碼。此命令會使用 Credential 參數,而且它會使用 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=135225</maml:uri>
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>about_Remote</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>about_PSSessions</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>New-PSSession</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Get-PSSession</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Remove-PSSession</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Enter-PSSession</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Exit-PSSession</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>WS-Management Provider</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>
Invoke-History
</command:name>
<maml:description>
<maml:para>執行工作階段歷程記錄中的命令。</maml:para>
</maml:description>
<maml:copyright>
<maml:para></maml:para>
</maml:copyright>
<command:verb>Invoke</command:verb>
<command:noun>History</command:noun>
<dev:version></dev:version>
</command:details>
<maml:description>
<maml:para>Invoke-History Cmdlet 會執行工作階段歷程記錄中的命令。您可以將代表 Get-History 所傳回命令的物件傳遞到 Invoke-History,也可以在目前歷程記錄中使用命令識別碼來識別這些命令。若要尋找命令的識別碼,請使用 Get-History。</maml:para>
</maml:description>
<!-- Cmdlet syntax section-->
<command:syntax>
<command:syntaxItem>
<maml:name>Invoke-History</maml:name>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="true (ByPropertyName)" position="1">
<maml:name>Id</maml:name>
<maml:description>
<maml:para>識別歷程記錄中的命令。可輸入命令的識別碼或是命令的前幾個字元。
如果輸入字元,Invoke-History 會先比對最近的命令。如果省略此參數,Invoke-History 將執行最後一個 (最近的) 命令。參數名稱 ("id") 為選擇項。若要尋找命令的識別碼,請使用 Get-History。</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="false" variableLength="false" globbing="false" pipelineInput="true (ByPropertyName)" position="1">
<maml:name>Id</maml:name>
<maml:description>
<maml:para>識別歷程記錄中的命令。可輸入命令的識別碼或是命令的前幾個字元。
如果輸入字元,Invoke-History 會先比對最近的命令。如果省略此參數,Invoke-History 將執行最後一個 (最近的) 命令。參數名稱 ("id") 為選擇項。若要尋找命令的識別碼,請使用 Get-History。</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>無</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>無</maml:name>
<maml:uri />
<maml:description />
</dev:type>
<maml:description>
<maml:para>
<!-- description -->
Invoke-History 不會產生任何輸出,但是 Invoke-History 執行的命令可能會產生輸出。
</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 便會將其新增至歷程記錄,讓您可以重複使用。如需工作階段歷程記錄的詳細資訊,請參閱 about_History。
您也可以利用內建的別名 "r" 和 "ihy" 來參照 Invoke-History。如需詳細資訊,請參閱 about_Aliases。
</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>
invoke-history </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個命令會執行工作階段歷程記錄中的最後一個 (最近的) 命令。您可以將這個命令縮寫成 "r" (理解成 "repeat" 或 "rerun"),也就是 Invoke-History 的別名。</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-history -id 132 </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個命令會執行工作階段歷程記錄中識別碼為 132 的命令。因為 Id 參數的名稱屬於選擇項,所以您可以將這個命令縮寫成 "Invoke-History 132"、"ihy 132" 或 "r 132"。</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-history get-pr </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個命令會執行工作階段歷程記錄中最近的 Get-Process 命令。當您針對 Id 參數輸入字元時,Invoke-History 就會執行它從這些最近命令開始找起而找到之符合該模式的第一個命令。這個命令會使用 ID 參數,不過它會省略選擇性參數名稱。</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>
invoke-history (16..24), 27 </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個命令會執行識別碼範圍 16 到 24 和識別碼 27 的命令。您可以列出多個識別碼和以逗號分隔的識別碼範圍。</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>
get-history -id 255 -count 7 | invoke-history </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個命令會執行歷程記錄中最後一個命令識別碼為 255 的前 7 個命令 (通常是 249 到 255 的命令)。它會使用 Get-History Cmdlet 擷取這些命令。管線運算子 (|) 會將這些命令傳遞到 Invoke-History,並由後者執行這些命令。</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=113344</maml:uri>
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>about_History</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Get-History</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Add-History</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Clear-History</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>
New-Module
</command:name>
<maml:description>
<maml:para>建立只存在於記憶體中的新動態模組。</maml:para>
</maml:description>
<maml:copyright>
<maml:para></maml:para>
</maml:copyright>
<command:verb>New</command:verb>
<command:noun>Module</command:noun>
<dev:version></dev:version>
</command:details>
<maml:description>
<maml:para>New-Module Cmdlet 會根據指令碼區塊建立動態模組。此動態模組的成員 (例如函數和變數) 可立即在工作階段中使用,而且其可用狀態將持續到您關閉工作階段為止。
與靜態模組一樣,系統預設將匯出動態模組中的 Cmdlet 和函數,但不匯出變數和別名。不過,您可以使用 Export-ModuleMember Cmdlet 和 New-Module 的參數來覆寫預設值。
動態模組只存在於記憶體中,不存在於磁碟。與所有模組一樣,動態模組的成員會在私人模組範圍 (屬於全域範圍的子系) 中執行。Get-Module 無法取得動態模組,但是 Get-Command 可以取得已匯出的成員。
若要讓 Get-Module 可以使用動態模組,請經由管道將 New-Module 命令輸出至 Import-Module,或是經由管道將 New-Module 傳回的模組物件輸出至 Import-Module。這個動作會將動態模組新增至 Get-Module 清單,但是不會將模組儲存到磁碟,或是讓它變成固定模組。</maml:para>
</maml:description>
<!-- Cmdlet syntax section-->
<command:syntax>
<command:syntaxItem>
<maml:name>New-Module</maml:name>
<command:parameter required="true" variableLength="false" globbing="false" pipelineInput="true (ByValue)" position="1">
<maml:name>Name</maml:name>
<maml:description>
<maml:para>指定新模組的名稱。您也可以經由管道將模組名稱輸出至 New-Module。
預設值是自動產生的名稱,其以 "__DynamicModule_" 開頭,後面再加上指定動態模組路徑的 GUID。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">string</command:parameterValue>
</command:parameter>
<command:parameter required="true" variableLength="false" globbing="false" pipelineInput="false" position="2">
<maml:name>ScriptBlock</maml:name>
<maml:description>
<maml:para>指定動態模組的內容。請以大括號 ( { } ) 括住內容以建立指令碼區塊。此參數為必要項。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">scriptblock</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="false" position="named">
<maml:name>ArgumentList</maml:name>
<maml:description>
<maml:para>指定傳遞至指令碼區塊的引數 (參數值)。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="true">Object[]</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>AsCustomObject</maml:name>
<maml:description>
<maml:para>傳回自訂物件,其成員表示模組成員。
當您使用 AsCustomObject 參數時,New-Module 會建立動態模組、將模組成員匯入至目前的工作階段,然後傳回 PSCustomObject 物件而非 PSModuleInfo 物件。您可以將自訂物件儲存到變數中,並使用點標記法來叫用成員。
如果此模組具有多個相同名稱的成員 (例如同時名為 "A" 的函數和變數),就只能從自訂物件存取具有個別名稱的單一成員。</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="true" pipelineInput="false" position="named">
<maml:name>Cmdlet</maml:name>
<maml:description>
<maml:para>只將指定的 Cmdlet 從模組匯出至目前的工作階段。請輸入以逗號分隔的 Cmdlet 清單。允許使用萬用字元。根據預設,系統將匯出模組中的所有 Cmdlet。
雖然您無法在指令碼區塊中定義 Cmdlet,不過如果動態模組從二進位模組中匯入 Cmdlet,它就可以包含 Cmdlet。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="true">string[]</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="true" pipelineInput="false" position="named">
<maml:name>Function</maml:name>
<maml:description>
<maml:para>只將指定的函數從模組匯出至目前的工作階段。請輸入以逗號分隔的函數清單。允許使用萬用字元。根據預設,系統將匯出模組中定義的所有函數。</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>ReturnResult</maml:name>
<maml:description>
<maml:para>執行指令碼區塊並傳回指令碼區塊的結果,而非傳回模組物件。</maml:para>
</maml:description>
</command:parameter>
</command:syntaxItem>
<command:syntaxItem>
<maml:name>New-Module</maml:name>
<command:parameter required="true" variableLength="false" globbing="false" pipelineInput="false" position="1">
<maml:name>ScriptBlock</maml:name>
<maml:description>
<maml:para>指定動態模組的內容。請以大括號 ( { } ) 括住內容以建立指令碼區塊。此參數為必要項。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">scriptblock</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="false" position="named">
<maml:name>ArgumentList</maml:name>
<maml:description>
<maml:para>指定傳遞至指令碼區塊的引數 (參數值)。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="true">Object[]</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>AsCustomObject</maml:name>
<maml:description>
<maml:para>傳回自訂物件,其成員表示模組成員。
當您使用 AsCustomObject 參數時,New-Module 會建立動態模組、將模組成員匯入至目前的工作階段,然後傳回 PSCustomObject 物件而非 PSModuleInfo 物件。您可以將自訂物件儲存到變數中,並使用點標記法來叫用成員。
如果此模組具有多個相同名稱的成員 (例如同時名為 "A" 的函數和變數),就只能從自訂物件存取具有個別名稱的單一成員。</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="true" pipelineInput="false" position="named">
<maml:name>Cmdlet</maml:name>
<maml:description>
<maml:para>只將指定的 Cmdlet 從模組匯出至目前的工作階段。請輸入以逗號分隔的 Cmdlet 清單。允許使用萬用字元。根據預設,系統將匯出模組中的所有 Cmdlet。
雖然您無法在指令碼區塊中定義 Cmdlet,不過如果動態模組從二進位模組中匯入 Cmdlet,它就可以包含 Cmdlet。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="true">string[]</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="true" pipelineInput="false" position="named">
<maml:name>Function</maml:name>
<maml:description>
<maml:para>只將指定的函數從模組匯出至目前的工作階段。請輸入以逗號分隔的函數清單。允許使用萬用字元。根據預設,系統將匯出模組中定義的所有函數。</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>ReturnResult</maml:name>
<maml:description>
<maml:para>執行指令碼區塊並傳回指令碼區塊的結果,而非傳回模組物件。</maml:para>
</maml:description>
</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>ArgumentList</maml:name>
<maml:description>
<maml:para>指定傳遞至指令碼區塊的引數 (參數值)。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="true">Object[]</command:parameterValue>
<dev:type>
<maml:name>Object[]</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>AsCustomObject</maml:name>
<maml:description>
<maml:para>傳回自訂物件,其成員表示模組成員。
當您使用 AsCustomObject 參數時,New-Module 會建立動態模組、將模組成員匯入至目前的工作階段,然後傳回 PSCustomObject 物件而非 PSModuleInfo 物件。您可以將自訂物件儲存到變數中,並使用點標記法來叫用成員。
如果此模組具有多個相同名稱的成員 (例如同時名為 "A" 的函數和變數),就只能從自訂物件存取具有個別名稱的單一成員。</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="true" pipelineInput="false" position="named">
<maml:name>Cmdlet</maml:name>
<maml:description>
<maml:para>只將指定的 Cmdlet 從模組匯出至目前的工作階段。請輸入以逗號分隔的 Cmdlet 清單。允許使用萬用字元。根據預設,系統將匯出模組中的所有 Cmdlet。
雖然您無法在指令碼區塊中定義 Cmdlet,不過如果動態模組從二進位模組中匯入 Cmdlet,它就可以包含 Cmdlet。</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="true" pipelineInput="false" position="named">
<maml:name>Function</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="true" variableLength="false" globbing="false" pipelineInput="true (ByValue)" position="1">
<maml:name>Name</maml:name>
<maml:description>
<maml:para>指定新模組的名稱。您也可以經由管道將模組名稱輸出至 New-Module。
預設值是自動產生的名稱,其以 "__DynamicModule_" 開頭,後面再加上指定動態模組路徑的 GUID。</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>"__DynamicModule_" + GUID</dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>ReturnResult</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>False</dev:defaultValue>
</command:parameter>
<command:parameter required="true" variableLength="false" globbing="false" pipelineInput="false" position="1">
<maml:name>ScriptBlock</maml:name>
<maml:description>
<maml:para>指定動態模組的內容。請以大括號 ( { } ) 括住內容以建立指令碼區塊。此參數為必要項。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">scriptblock</command:parameterValue>
<dev:type>
<maml:name>scriptblock</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 -->
您可以經由管道將名稱字串輸出至 New-Module。
</maml:para>
</maml:description>
</command:inputType>
</command:inputTypes>
<command:returnValues>
<command:returnValue>
<dev:type>
<maml:name>System.Management.Automation.PSModuleInfo、System.Management.Automation.PSCustomObject 或無</maml:name>
<maml:uri />
<maml:description />
</dev:type>
<maml:description>
<maml:para>
<!-- description -->
根據預設,New-Module 會產生 PSModuleInfo 物件。如果使用 AsCustomObject 參數,則會產生 PSCustomObject 物件。如果使用 ReturnResult 參數,則會傳回動態模組中指令碼區塊的評估結果。
</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>
您也可以利用 New-Module 的別名 ("nmo") 來表示此 Cmdlet。如需詳細資訊,請參閱 about_Aliases。
</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>
new-module -scriptblock {function Hello {"Hello!"}}
Name : __DynamicModule_2ceb1d0a-990f-45e4-9fe4-89f0f6ead0e5
Path : 2ceb1d0a-990f-45e4-9fe4-89f0f6ead0e5
Description :
Guid : 00000000-0000-0000-0000-000000000000
Version : 0.0
ModuleBase :
ModuleType : Script
PrivateData :
AccessMode : ReadWrite
ExportedAliases : {}
ExportedCmdlets : {}
ExportedFunctions : {[Hello, Hello]}
ExportedVariables : {}
NestedModules : {} </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個命令會建立包含名為 "Hello" 之函數的新動態模組,並傳回代表新動態模組的模組物件。</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>
new-module -scriptblock {function Hello {"Hello!"}}
Name : __DynamicModule_2ceb1d0a-990f-45e4-9fe4-89f0f6ead0e5
Path : 2ceb1d0a-990f-45e4-9fe4-89f0f6ead0e5
Description :
Guid : 00000000-0000-0000-0000-000000000000
Version : 0.0
ModuleBase :
ModuleType : Script
PrivateData :
AccessMode : ReadWrite
ExportedAliases : {}
ExportedCmdlets : {}
ExportedFunctions : {[Hello, Hello]}
ExportedVariables : {}
NestedModules : {}
C:\PS> get-module
C:\PS>
C:\PS> get-command Hello
CommandType Name Definition
----------- ---- ----------
Function Hello "Hello!"
</dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個範例會示範 Get-Module Cmdlet 不會傳回動態模組,但是 Get-Command 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>
-------------------------- 範例 3 --------------------------
</maml:title>
<maml:introduction>
<maml:para>C:\PS></maml:para>
</maml:introduction>
<dev:code>
New-Module -scriptblock {$SayHelloHelp="Type 'SayHello', a space, and a name."; function SayHello ($name) { "Hello, $name" }; Export-ModuleMember -function SayHello -Variable SayHelloHelp}
C:\PS> $SayHelloHelp
Type 'SayHello', a space, and a name.
C:\PS> SayHello Jeffrey
Hello, Jeffrey </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個命令會使用 Export-ModuleMember Cmdlet,將變數匯出至目前的工作階段。如果沒有使用 Export-ModuleMember 命令,就只會匯出函數。
其輸出顯示變數和函數都已匯出至工作階段。</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>
new-module -scriptblock {function Hello {"Hello!"}} -name GreetingModule | import-module
C:\PS> get-module
Name : GreetingModule
Path : d54dfdac-4531-4db2-9dec-0b4b9c57a1e5
Description :
Guid : 00000000-0000-0000-0000-000000000000
Version : 0.0
ModuleBase :
ModuleType : Script
PrivateData :
AccessMode : ReadWrite
ExportedAliases : {}
ExportedCmdlets : {}
ExportedFunctions : {[Hello, Hello]}
ExportedVariables : {}
NestedModules : {}
C:\PS> get-command hello
CommandType Name Definition
----------- ---- ----------
Function Hello "Hello!"
</dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個命令說明您可以經由管道將動態模組輸出至 Import-Module Cmdlet,讓 Get-Module Cmdlet 可以使用動態模組。
第一個命令會使用管線運算子 (|),將 New-Module 產生的模組物件傳送給 Import-Module Cmdlet。這個命令會使用 New-Module 的 Name 參數,將好記的名稱指定給模組。因為 Import-Module 預設不會傳回任何物件,所以這個命令沒有任何輸出。
第二個命令會使用 Get-Module Cmdlet 取得工作階段中的模組。其結果顯示 Get-Module 可以取得新的動態模組。
第三個命令會使用 Get-Command Cmdlet 取得動態模組所匯出的 Hello 函數。</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>
$m = new-module -scriptblock {function Hello ($name) {"Hello, $name"}; function Goodbye ($name) {"Goodbye, $name"}} -AsCustomObject
C:\PS> $m
C:\PS> $m | get-member
TypeName: System.Management.Automation.PSCustomObject
Name MemberType Definition
---- ---------- ----------
Equals Method bool Equals(System.Object obj)
GetHashCode Method int GetHashCode()
GetType Method type GetType()
ToString Method string ToString()
Goodbye ScriptMethod System.Object Goodbye();
Hello ScriptMethod System.Object Hello();
PS C:\ps-test> $m.goodbye("Jane")
Goodbye, Jane
PS C:\ps-test> $m.hello("Manoj")
Hello, Manoj
PS C:\ps-test> goodbye Jane
Goodbye, Jane
PS C:\ps-test> hello Manoj
Hello, Manoj
</dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>在這個範例中,會示範如何使用 New-Module 的 AsCustomObject 參數來產生自訂物件,其中包含表示已匯出之函數的指令碼方法。
第一個命令會使用 New-Module Cmdlet,產生具有 Hello 和 Goodbye 兩個函數的動態模組。這個命令會使用 AsCustomObject 參數來產生自訂物件,而非 New-Module 預設產生的 PSModuleInfo 物件,然後將此自訂物件儲存在 $m 變數中。
第二個命令會嘗試顯示 $m 變數的值,但不會出現任何內容。
第三個命令會使用管線運算子 (|),將自訂物件傳送給 Get-Member Cmdlet,此 Cmdlet 會顯示自訂物件的屬性和方法。其輸出顯示此物件具有表示 Hello 和 Goodbye 函數的指令碼方法。
第四和第五個命令會使用指令碼方法格式來呼叫 Hello 和 Goodbye 函數。
第六和第七個命令會指定函數名稱與參數值,藉以呼叫這些函數。</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>
new-module -scriptblock {function SayHello {"Hello, World!"}; SayHello} -returnResult
Hello, World! </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個命令會使用 ReturnResult 參數來要求執行指令碼區塊的結果,而非要求模組物件。
新模組中的指令碼區塊會定義 SayHello 函數,然後呼叫此函數。</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=141554</maml:uri>
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Get-Module</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Import-Module</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Remove-Module</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Export-ModuleMember</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>about_Modules</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>
New-ModuleManifest
</command:name>
<maml:description>
<maml:para>建立新的模組資訊清單。</maml:para>
</maml:description>
<maml:copyright>
<maml:para></maml:para>
</maml:copyright>
<command:verb>New</command:verb>
<command:noun>ModuleManifest</command:noun>
<dev:version></dev:version>
</command:details>
<maml:description>
<maml:para>New-ModuleManifest Cmdlet 會建立新的模組資訊清單 (.psd1) 檔案、填入其值,並且以指定的路徑來儲存資訊清單檔案。
模組作者可以使用這個 Cmdlet 來建立其模組的資訊清單。模組資訊清單是包含雜湊表的 .psd1 檔案。雜湊表中的索引鍵和值會描述模組的內容和屬性、定義必要條件,以及決定元件的處理方式。模組不需要有資訊清單。
New-ModuleManifest 會建立內含所有常用資訊清單索引鍵的資訊清單,因此您可以使用此預設輸出做為資訊清單範本。若要新增或變更值,或是新增此 Cmdlet 不會新增的模組索引鍵,請在文字編輯器中開啟產生的檔案。
此 Cmdlet 的每個參數 (Path 和 PassThru 除外) 都會建立模組資訊清單索引鍵及其值。在模組資訊清單中,只有 ModuleVersion 索引鍵是必要項。不過,此 Cmdlet 還有其他幾個必要的參數。因此,您可以輸入 "New-ModuleManifest" 命令且不指定參數,讓 Cmdlet 提示您輸入其他常用索引鍵的值。若要將值保留空白,請按 ENTER。
如需模組資訊清單之格式、作用和需求的完整描述,請參閱 MSDN (Microsoft Developer Network) Library 中的<如何撰寫模組資訊清單>(英文),網址為:http://go.microsoft.com/fwlink/?LinkId=143613。
</maml:para>
</maml:description>
<!-- Cmdlet syntax section-->
<command:syntax>
<command:syntaxItem>
<maml:name>New-ModuleManifest</maml:name>
<command:parameter required="true" variableLength="false" globbing="false" pipelineInput="false" position="1">
<maml:name>Path</maml:name>
<maml:description>
<maml:para>指定新模組資訊清單的路徑和檔名。請輸入路徑及副檔名為 .psd1 的檔名,例如 "$pshome\Modules\MyModule\MyModule.psd1"。此參數為必要項。
如果指定現有檔案的路徑,除非該檔案擁有唯讀屬性,否則 New-ModuleManifest 便會取代檔案而不顯示警告。
資訊清單必須位於模組的目錄中,而且資訊清單檔案名稱必須與模組目錄名稱相同,但是副檔名為 .psd1。
注意:出現提示要求輸入 Path 參數的值時,您不能使用變數 (例如 $pshome 或 $home) 來回應。若要使用變數,請在命令中包含 Path 參數。
</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">string</command:parameterValue>
</command:parameter>
<command:parameter required="true" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>Author</maml:name>
<maml:description>
<maml:para>指定模組作者。
此參數是 Cmdlet 的必要項,但是 Author 索引鍵不是資訊清單的必要項。如果省略此參數,且未於出現提示時輸入值,New-ModuleManifest 就會建立值為目前使用者名稱的 Author 索引鍵。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">string</command:parameterValue>
</command:parameter>
<command:parameter required="true" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>CompanyName</maml:name>
<maml:description>
<maml:para>識別建立模組的公司或廠商。
此參數是 Cmdlet 的必要項,但是 CompanyName 索引鍵不是資訊清單的必要項。如果省略此參數,且未於出現提示時輸入值,New-ModuleManifest 就會建立值為 "Unknown" 的 CompanyName 索引鍵。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">string</command:parameterValue>
</command:parameter>
<command:parameter required="true" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>Copyright</maml:name>
<maml:description>
<maml:para>指定模組的著作權聲明。
此參數是 Cmdlet 的必要項,但是 Copyright 索引鍵不是資訊清單的必要項。如果省略此參數,且未於出現提示時輸入值,New-ModuleManifest 就會建立值為 "(c) <年份> <使用者名稱>. All rights reserved."的 Copyright 索引鍵,其中 <年份> 是目前的年份,而 <使用者名稱> 是 Author 索引鍵的值 (如果有指定的話) 或目前使用者的名稱。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">string</command:parameterValue>
</command:parameter>
<command:parameter required="true" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>Description</maml:name>
<maml:description>
<maml:para>描述模組的內容。
此參數是 Cmdlet 的必要項,但是 Description 索引鍵不是資訊清單的必要項。如果省略此參數,且未於出現提示時輸入值,New-ModuleManifest 就會建立值為空字串的 Description 索引鍵。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">string</command:parameterValue>
</command:parameter>
<command:parameter required="true" variableLength="true" globbing="false" pipelineInput="false" position="named">
<maml:name>FileList</maml:name>
<maml:description>
<maml:para>指定模組中包含的所有項目。
這個索引鍵是設計成當做模組清查使用。這些檔案不會自動隨模組一起匯出。
此參數是 Cmdlet 的必要項,但是 FileList 索引鍵不是資訊清單的必要項。如果省略此參數,且未於出現提示時輸入值,New-ModuleManifest 就會建立值為空陣列的 FileList 索引鍵。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="true">string[]</command:parameterValue>
</command:parameter>
<command:parameter required="true" variableLength="true" globbing="false" pipelineInput="false" position="named">
<maml:name>FormatsToProcess</maml:name>
<maml:description>
<maml:para>指定匯入模組時要執行的格式化檔案 (.ps1xml)。
當您匯入模組時,Windows PowerShell 就會使用指定的檔案來執行 Update-FormatData Cmdlet。因為格式化檔案沒有限定範圍,所以它們會影響工作階段中的所有工作階段狀態。
此參數是 Cmdlet 的必要項,但是 FormatsToProcess 索引鍵不是資訊清單的必要項。如果省略此參數,且未於出現提示時輸入值,New-ModuleManifest 就會建立值為空陣列的 FormatsToProcess 索引鍵。</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="named">
<maml:name>ModuleToProcess</maml:name>
<maml:description>
<maml:para>指定模組的主要檔案或「根」檔案。匯入模組時,從根模組檔案匯出的成員都會匯入呼叫者的工作階段狀態中。請輸入一個指令碼模組 (.psm1) 或二進位模組 (.dll) 的檔案名稱。
如果模組具有資訊清單檔案,而且尚未在 ModuleToProcess 索引鍵中指定任何根檔案,資訊清單就會變成模組的主要檔案,而模組也會變成「資訊清單模組」(ModuleType = Manifest)。
若要從具有資訊清單之模組中的 .psm1 或 .dll 檔案匯出成員,您必須在資訊清單的 ModuleToProcess 或 NestedModules 索引鍵值中指定這些檔案的名稱。否則,系統就不會匯出這些檔案的成員。
此參數是 Cmdlet 的必要項,但是 ModuleToProcess 索引鍵不是資訊清單的必要項。如果省略此參數,且未於出現提示時輸入值,New-ModuleManifest 就會建立值為空字串的 ModuleToProcess 索引鍵。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">string</command:parameterValue>
</command:parameter>
<command:parameter required="true" variableLength="true" globbing="false" pipelineInput="false" position="named">
<maml:name>NestedModules</maml:name>
<maml:description>
<maml:para>指定要匯入模組之工作階段狀態中的指令碼模組 (.psm1) 和二進位模組 (.dll)。NestedModules 索引鍵中的檔案會依照它們列在值中的順序執行。
一般而言,巢狀模組會包含根模組進行內部處理所需的命令。根據預設,巢狀模組中的命令會從模組的工作階段狀態匯出至呼叫者的工作階段狀態中,但是根模組可以限制它所匯出的命令 (例如,使用 Export-Module 命令)。
雖然根模組可以使用模組工作階段狀態中的巢狀模組,不過呼叫者工作階段中的 Get-Module 命令不會傳回這些模組。
列於 NestedModules 索引鍵中的指令碼 (.ps1) 是在模組的工作階段狀態中執行,而不是在呼叫者的工作階段中執行。若要在呼叫者的工作階段狀態中執行指令碼,請在資訊清單的 ScriptsToProcess 索引鍵值中列出指令碼檔案名稱。
此參數是 Cmdlet 的必要項,但是 NestedModules 索引鍵不是資訊清單的必要項。如果省略此參數,且未於出現提示時輸入值,New-ModuleManifest 就會建立值為空陣列的 NestedModules 索引鍵。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="true">string[]</command:parameterValue>
</command:parameter>
<command:parameter required="true" variableLength="true" globbing="false" pipelineInput="false" position="named">
<maml:name>RequiredAssemblies</maml:name>
<maml:description>
<maml:para>指定模組需要的組件 (.dll) 檔案。Windows PowerShell 會先載入指定的組件,然後再更新類型或格式、匯入巢狀模組,或匯入 ModuleToProcess 索引鍵值中指定的模組檔案。
請使用這個參數來列出模組所需的所有組件,包括必須載入以更新 FormatsToProcess 或 TypesToProcess 索引鍵中所列之任何格式化檔案或類型檔案的組件,即使這些組件也在 NestedModules 索引鍵中列為二進位模組也一樣。
此參數是 Cmdlet 的必要項,但是 RequiredAssemblies 索引鍵不是資訊清單的必要項。如果省略此參數,且未於出現提示時輸入值,New-ModuleManifest 就會建立值為空陣列的 RequiredAssemblies 索引鍵。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="true">string[]</command:parameterValue>
</command:parameter>
<command:parameter required="true" variableLength="true" globbing="false" pipelineInput="false" position="named">
<maml:name>TypesToProcess</maml:name>
<maml:description>
<maml:para>指定匯入模組時要執行的類型檔案 (.ps1xml)。
當您匯入模組時,Windows PowerShell 就會使用指定的檔案來執行 Update-TypeData Cmdlet。因為類型檔案沒有限定範圍,所以它們會影響工作階段中的所有工作階段狀態。
此參數是 Cmdlet 的必要項,但是 TypesToProcess 索引鍵不是資訊清單的必要項。如果省略此參數,且未於出現提示時輸入值,New-ModuleManifest 就會建立值為空陣列的 TypesToProcess 索引鍵。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="true">string[]</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="true" pipelineInput="false" position="named">
<maml:name>AliasesToExport</maml:name>
<maml:description>
<maml:para>指定模組匯出的別名。允許使用萬用字元。
您可以使用此參數來限制模組所匯出的別名。它可以從已匯出的別名清單中移除別名,但是不能在清單中新增別名。
如果您省略此參數,New-ModuleManifest 就會建立值為 * (全部) 的 AliasesToExport 索引鍵,表示資訊清單將匯出該模組所匯出的所有別名。</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>ClrVersion</maml:name>
<maml:description>
<maml:para>指定模組需要的 Microsoft .NET Framework Common Language Runtime (CLR) 版本。
如果省略此參數,New-ModuleManifest 會建立值為空字串的 CLRVersion 索引鍵。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">Version</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="true" pipelineInput="false" position="named">
<maml:name>CmdletsToExport</maml:name>
<maml:description>
<maml:para>指定模組匯出的 Cmdlet。允許使用萬用字元。
您可以使用此參數來限制模組所匯出的 Cmdlet。它可以從已匯出的 Cmdlet 清單中移除 Cmdlet,但是不能在清單中新增 Cmdlet。
如果您省略此參數,New-ModuleManifest 就會建立值為 * (全部) 的 CmdletsToExport 索引鍵,表示資訊清單將匯出該模組所匯出的所有 Cmdlet。</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>DotNetFrameworkVersion</maml:name>
<maml:description>
<maml:para>指定模組需要的 Microsoft .NET Framework 版本。
如果省略此參數,New-ModuleManifest 會建立值為空字串的 DotNetFrameWorkVersion 索引鍵。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">Version</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="true" pipelineInput="false" position="named">
<maml:name>FunctionsToExport</maml:name>
<maml:description>
<maml:para>指定模組匯出的函數。允許使用萬用字元。
您可以使用此參數來限制模組所匯出的函數。它可以從已匯出的別名清單中移除函數,但是不能在清單中新增函數。
如果您省略此參數,New-ModuleManifest 就會建立值為 * (全部) 的 FunctionsToExport 索引鍵,表示資訊清單將匯出該模組所匯出的所有函數。</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>Guid</maml:name>
<maml:description>
<maml:para>指定模組的唯一識別碼。此 GUID 可用來分辨名稱相同的模組。
如果省略此參數,New-ModuleManifest 會在資訊清單中建立 GUID 索引鍵,並產生 GUID 做為其值。
若要在 Windows PowerShell 中建立新的 GUID,請輸入 "[guid]::NewGuid()"。
</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">Guid</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="false" position="named">
<maml:name>ModuleList</maml:name>
<maml:description>
<maml:para>列出與這個模組一起封裝的所有模組。
請以字串形式輸入每個模組名稱,或輸入具有 ModuleName 和 GUID 索引鍵的雜湊表。此雜湊表也可以具有選擇性 ModuleVersion 索引鍵。
這個索引鍵是設計成當做模組清查使用。系統不會自動處理這些模組。
如果省略此參數,New-ModuleManifest 就會在資訊清單中建立值為空陣列的 ModuleList 索引鍵。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="true">Object[]</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>ModuleVersion</maml:name>
<maml:description>
<maml:para>指定模組的版本。
此參數不是 Cmdlet 的必要項,但是 ModuleVersion 索引鍵是資訊清單的必要項。如果省略此參數,New-ModuleManifest 會建立值為 "1.0" 的 ModuleVersion 索引鍵。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">Version</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>除了建立 .psd1 檔案之外,還會將產生的模組資訊清單寫入主控台。根據預設,此 Cmdlet 不會產生任何輸出。</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>PowerShellHostName</maml:name>
<maml:description>
<maml:para>指定模組所需之 Windows PowerShell 主機程式的名稱。請輸入主機程式的名稱,例如 "Windows PowerShell ISE Host" 或 "ConsoleHost"。不允許使用萬用字元。
若要尋找主機程式的名稱,請在程式中,輸入 "$host.name"。
如果省略此參數,New-ModuleManifest 會建立值為空字串的 PowerShellHostName 索引鍵。</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>PowerShellHostVersion</maml:name>
<maml:description>
<maml:para>指定將搭配此模組使用的最小 Windows PowerShell 主機程式版本。請輸入版本號碼,例如 1.1。
如果省略此參數,New-ModuleManifest 會建立值為空字串的 PowerShellHostName 索引鍵。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">Version</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>PowerShellVersion</maml:name>
<maml:description>
<maml:para>指定將搭配此模組使用的最小 Windows PowerShell 版本。請輸入 1.0 或 2.0。您不一定非要使用 2.0 版。
如果省略此參數,New-ModuleManifest 會建立值為空字串的 PowerShellVersion 索引鍵。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">Version</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>PrivateData</maml:name>
<maml:description>
<maml:para>指定在匯入模組時傳遞至模組的資料。
如果省略此參數,New-ModuleManifest 會建立值為空字串的 PrivateData 索引鍵。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">Object</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>ProcessorArchitecture</maml:name>
<maml:description>
<maml:para>指定模組所需的處理器架構。有效的值包括 x86、AMD64、IA64 和 None (未知或未指定)。
如果省略此參數,New-ModuleManifest 會建立值為空字串的 ProcessorArchitecture 索引鍵。</maml:para>
</maml:description>
<command:parameterValueGroup>
<command:parameterValue required="false" variableLength="false">None</command:parameterValue>
<command:parameterValue required="false" variableLength="false">MSIL</command:parameterValue>
<command:parameterValue required="false" variableLength="false">X86</command:parameterValue>
<command:parameterValue required="false" variableLength="false">IA64</command:parameterValue>
<command:parameterValue required="false" variableLength="false">Amd64</command:parameterValue>
</command:parameterValueGroup>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="false" position="named">
<maml:name>RequiredModules</maml:name>
<maml:description>
<maml:para>指定必須位於全域工作階段狀態中的模組。如果所需的模組沒有位於全域工作階段狀態中,嘗試匯入此模組的作業將會失敗。
請以字串形式輸入每個模組名稱,或輸入具有 ModuleName 和 GUID 索引鍵的雜湊表。此雜湊表也可以具有選擇性 ModuleVersion 索引鍵。如需詳細資訊,請參閱範例。
Windows PowerShell 不會自動匯入所需的模組。它只會確認所需的模組是否存在。不過,模組可以包含將所需模組匯入全域工作階段狀態中的指令碼 (.ps1)。
如果省略此參數,New-ModuleManifest 會建立值為空陣列的 RequiredModules 索引鍵。
</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="true">Object[]</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="false" position="named">
<maml:name>ScriptsToProcess</maml:name>
<maml:description>
<maml:para>指定匯入模組時要在呼叫者之工作階段狀態中執行的指令碼 (.ps1) 檔案。您可以使用這些指令碼來準備環境,就如同使用登入指令碼一樣。
若要指定在模組之工作階段狀態中執行的指令碼,請使用 NestedModules 索引鍵。
如果省略此參數,New-ModuleManifest 會建立值為空陣列的 ScriptsToProcess 索引鍵。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="true">string[]</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="true" pipelineInput="false" position="named">
<maml:name>VariablesToExport</maml:name>
<maml:description>
<maml:para>指定模組匯出的變數。允許使用萬用字元。
您可以使用此參數來限制模組所匯出的變數。它可以從已匯出的變數清單中移除變數,但是不能在清單中新增變數。
如果您省略此參數,New-ModuleManifest 就會建立值為 * (全部) 的 VariablesToExport 索引鍵,表示資訊清單將匯出該模組所匯出的所有變數。</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>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="false" variableLength="true" globbing="true" pipelineInput="false" position="named">
<maml:name>AliasesToExport</maml:name>
<maml:description>
<maml:para>指定模組匯出的別名。允許使用萬用字元。
您可以使用此參數來限制模組所匯出的別名。它可以從已匯出的別名清單中移除別名,但是不能在清單中新增別名。
如果您省略此參數,New-ModuleManifest 就會建立值為 * (全部) 的 AliasesToExport 索引鍵,表示資訊清單將匯出該模組所匯出的所有別名。</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="true" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>Author</maml:name>
<maml:description>
<maml:para>指定模組作者。
此參數是 Cmdlet 的必要項,但是 Author 索引鍵不是資訊清單的必要項。如果省略此參數,且未於出現提示時輸入值,New-ModuleManifest 就會建立值為目前使用者名稱的 Author 索引鍵。</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>ClrVersion</maml:name>
<maml:description>
<maml:para>指定模組需要的 Microsoft .NET Framework Common Language Runtime (CLR) 版本。
如果省略此參數,New-ModuleManifest 會建立值為空字串的 CLRVersion 索引鍵。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">Version</command:parameterValue>
<dev:type>
<maml:name>Version</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>無</dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="true" pipelineInput="false" position="named">
<maml:name>CmdletsToExport</maml:name>
<maml:description>
<maml:para>指定模組匯出的 Cmdlet。允許使用萬用字元。
您可以使用此參數來限制模組所匯出的 Cmdlet。它可以從已匯出的 Cmdlet 清單中移除 Cmdlet,但是不能在清單中新增 Cmdlet。
如果您省略此參數,New-ModuleManifest 就會建立值為 * (全部) 的 CmdletsToExport 索引鍵,表示資訊清單將匯出該模組所匯出的所有 Cmdlet。</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="true" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>CompanyName</maml:name>
<maml:description>
<maml:para>識別建立模組的公司或廠商。
此參數是 Cmdlet 的必要項,但是 CompanyName 索引鍵不是資訊清單的必要項。如果省略此參數,且未於出現提示時輸入值,New-ModuleManifest 就會建立值為 "Unknown" 的 CompanyName 索引鍵。</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="true" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>Copyright</maml:name>
<maml:description>
<maml:para>指定模組的著作權聲明。
此參數是 Cmdlet 的必要項,但是 Copyright 索引鍵不是資訊清單的必要項。如果省略此參數,且未於出現提示時輸入值,New-ModuleManifest 就會建立值為 "(c) <年份> <使用者名稱>. All rights reserved."的 Copyright 索引鍵,其中 <年份> 是目前的年份,而 <使用者名稱> 是 Author 索引鍵的值 (如果有指定的話) 或目前使用者的名稱。</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>(c) <年份> <使用者名稱>. All rights reserved.</dev:defaultValue>
</command:parameter>
<command:parameter required="true" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>Description</maml:name>
<maml:description>
<maml:para>描述模組的內容。
此參數是 Cmdlet 的必要項,但是 Description 索引鍵不是資訊清單的必要項。如果省略此參數,且未於出現提示時輸入值,New-ModuleManifest 就會建立值為空字串的 Description 索引鍵。</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>DotNetFrameworkVersion</maml:name>
<maml:description>
<maml:para>指定模組需要的 Microsoft .NET Framework 版本。
如果省略此參數,New-ModuleManifest 會建立值為空字串的 DotNetFrameWorkVersion 索引鍵。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">Version</command:parameterValue>
<dev:type>
<maml:name>Version</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>無</dev:defaultValue>
</command:parameter>
<command:parameter required="true" variableLength="true" globbing="false" pipelineInput="false" position="named">
<maml:name>FileList</maml:name>
<maml:description>
<maml:para>指定模組中包含的所有項目。
這個索引鍵是設計成當做模組清查使用。這些檔案不會自動隨模組一起匯出。
此參數是 Cmdlet 的必要項,但是 FileList 索引鍵不是資訊清單的必要項。如果省略此參數,且未於出現提示時輸入值,New-ModuleManifest 就會建立值為空陣列的 FileList 索引鍵。</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="true" variableLength="true" globbing="false" pipelineInput="false" position="named">
<maml:name>FormatsToProcess</maml:name>
<maml:description>
<maml:para>指定匯入模組時要執行的格式化檔案 (.ps1xml)。
當您匯入模組時,Windows PowerShell 就會使用指定的檔案來執行 Update-FormatData Cmdlet。因為格式化檔案沒有限定範圍,所以它們會影響工作階段中的所有工作階段狀態。
此參數是 Cmdlet 的必要項,但是 FormatsToProcess 索引鍵不是資訊清單的必要項。如果省略此參數,且未於出現提示時輸入值,New-ModuleManifest 就會建立值為空陣列的 FormatsToProcess 索引鍵。</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="true" pipelineInput="false" position="named">
<maml:name>FunctionsToExport</maml:name>
<maml:description>
<maml:para>指定模組匯出的函數。允許使用萬用字元。
您可以使用此參數來限制模組所匯出的函數。它可以從已匯出的別名清單中移除函數,但是不能在清單中新增函數。
如果您省略此參數,New-ModuleManifest 就會建立值為 * (全部) 的 FunctionsToExport 索引鍵,表示資訊清單將匯出該模組所匯出的所有函數。</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>Guid</maml:name>
<maml:description>
<maml:para>指定模組的唯一識別碼。此 GUID 可用來分辨名稱相同的模組。
如果省略此參數,New-ModuleManifest 會在資訊清單中建立 GUID 索引鍵,並產生 GUID 做為其值。
若要在 Windows PowerShell 中建立新的 GUID,請輸入 "[guid]::NewGuid()"。
</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">Guid</command:parameterValue>
<dev:type>
<maml:name>Guid</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>為模組產生的的 GUID</dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="false" position="named">
<maml:name>ModuleList</maml:name>
<maml:description>
<maml:para>列出與這個模組一起封裝的所有模組。
請以字串形式輸入每個模組名稱,或輸入具有 ModuleName 和 GUID 索引鍵的雜湊表。此雜湊表也可以具有選擇性 ModuleVersion 索引鍵。
這個索引鍵是設計成當做模組清查使用。系統不會自動處理這些模組。
如果省略此參數,New-ModuleManifest 就會在資訊清單中建立值為空陣列的 ModuleList 索引鍵。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="true">Object[]</command:parameterValue>
<dev:type>
<maml:name>Object[]</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>無</dev:defaultValue>
</command:parameter>
<command:parameter required="true" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>ModuleToProcess</maml:name>
<maml:description>
<maml:para>指定模組的主要檔案或「根」檔案。匯入模組時,從根模組檔案匯出的成員都會匯入呼叫者的工作階段狀態中。請輸入一個指令碼模組 (.psm1) 或二進位模組 (.dll) 的檔案名稱。
如果模組具有資訊清單檔案,而且尚未在 ModuleToProcess 索引鍵中指定任何根檔案,資訊清單就會變成模組的主要檔案,而模組也會變成「資訊清單模組」(ModuleType = Manifest)。
若要從具有資訊清單之模組中的 .psm1 或 .dll 檔案匯出成員,您必須在資訊清單的 ModuleToProcess 或 NestedModules 索引鍵值中指定這些檔案的名稱。否則,系統就不會匯出這些檔案的成員。
此參數是 Cmdlet 的必要項,但是 ModuleToProcess 索引鍵不是資訊清單的必要項。如果省略此參數,且未於出現提示時輸入值,New-ModuleManifest 就會建立值為空字串的 ModuleToProcess 索引鍵。</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>ModuleVersion</maml:name>
<maml:description>
<maml:para>指定模組的版本。
此參數不是 Cmdlet 的必要項,但是 ModuleVersion 索引鍵是資訊清單的必要項。如果省略此參數,New-ModuleManifest 會建立值為 "1.0" 的 ModuleVersion 索引鍵。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">Version</command:parameterValue>
<dev:type>
<maml:name>Version</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>1.0</dev:defaultValue>
</command:parameter>
<command:parameter required="true" variableLength="true" globbing="false" pipelineInput="false" position="named">
<maml:name>NestedModules</maml:name>
<maml:description>
<maml:para>指定要匯入模組之工作階段狀態中的指令碼模組 (.psm1) 和二進位模組 (.dll)。NestedModules 索引鍵中的檔案會依照它們列在值中的順序執行。
一般而言,巢狀模組會包含根模組進行內部處理所需的命令。根據預設,巢狀模組中的命令會從模組的工作階段狀態匯出至呼叫者的工作階段狀態中,但是根模組可以限制它所匯出的命令 (例如,使用 Export-Module 命令)。
雖然根模組可以使用模組工作階段狀態中的巢狀模組,不過呼叫者工作階段中的 Get-Module 命令不會傳回這些模組。
列於 NestedModules 索引鍵中的指令碼 (.ps1) 是在模組的工作階段狀態中執行,而不是在呼叫者的工作階段中執行。若要在呼叫者的工作階段狀態中執行指令碼,請在資訊清單的 ScriptsToProcess 索引鍵值中列出指令碼檔案名稱。
此參數是 Cmdlet 的必要項,但是 NestedModules 索引鍵不是資訊清單的必要項。如果省略此參數,且未於出現提示時輸入值,New-ModuleManifest 就會建立值為空陣列的 NestedModules 索引鍵。</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>除了建立 .psd1 檔案之外,還會將產生的模組資訊清單寫入主控台。根據預設,此 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>False</dev:defaultValue>
</command:parameter>
<command:parameter required="true" variableLength="false" globbing="false" pipelineInput="false" position="1">
<maml:name>Path</maml:name>
<maml:description>
<maml:para>指定新模組資訊清單的路徑和檔名。請輸入路徑及副檔名為 .psd1 的檔名,例如 "$pshome\Modules\MyModule\MyModule.psd1"。此參數為必要項。
如果指定現有檔案的路徑,除非該檔案擁有唯讀屬性,否則 New-ModuleManifest 便會取代檔案而不顯示警告。
資訊清單必須位於模組的目錄中,而且資訊清單檔案名稱必須與模組目錄名稱相同,但是副檔名為 .psd1。
注意:出現提示要求輸入 Path 參數的值時,您不能使用變數 (例如 $pshome 或 $home) 來回應。若要使用變數,請在命令中包含 Path 參數。
</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>PowerShellHostName</maml:name>
<maml:description>
<maml:para>指定模組所需之 Windows PowerShell 主機程式的名稱。請輸入主機程式的名稱,例如 "Windows PowerShell ISE Host" 或 "ConsoleHost"。不允許使用萬用字元。
若要尋找主機程式的名稱,請在程式中,輸入 "$host.name"。
如果省略此參數,New-ModuleManifest 會建立值為空字串的 PowerShellHostName 索引鍵。</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>PowerShellHostVersion</maml:name>
<maml:description>
<maml:para>指定將搭配此模組使用的最小 Windows PowerShell 主機程式版本。請輸入版本號碼,例如 1.1。
如果省略此參數,New-ModuleManifest 會建立值為空字串的 PowerShellHostName 索引鍵。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">Version</command:parameterValue>
<dev:type>
<maml:name>Version</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>PowerShellVersion</maml:name>
<maml:description>
<maml:para>指定將搭配此模組使用的最小 Windows PowerShell 版本。請輸入 1.0 或 2.0。您不一定非要使用 2.0 版。
如果省略此參數,New-ModuleManifest 會建立值為空字串的 PowerShellVersion 索引鍵。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">Version</command:parameterValue>
<dev:type>
<maml:name>Version</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>PrivateData</maml:name>
<maml:description>
<maml:para>指定在匯入模組時傳遞至模組的資料。
如果省略此參數,New-ModuleManifest 會建立值為空字串的 PrivateData 索引鍵。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">Object</command:parameterValue>
<dev:type>
<maml:name>Object</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>ProcessorArchitecture</maml:name>
<maml:description>
<maml:para>指定模組所需的處理器架構。有效的值包括 x86、AMD64、IA64 和 None (未知或未指定)。
如果省略此參數,New-ModuleManifest 會建立值為空字串的 ProcessorArchitecture 索引鍵。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">ProcessorArchitecture</command:parameterValue>
<dev:type>
<maml:name>ProcessorArchitecture</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>無</dev:defaultValue>
</command:parameter>
<command:parameter required="true" variableLength="true" globbing="false" pipelineInput="false" position="named">
<maml:name>RequiredAssemblies</maml:name>
<maml:description>
<maml:para>指定模組需要的組件 (.dll) 檔案。Windows PowerShell 會先載入指定的組件,然後再更新類型或格式、匯入巢狀模組,或匯入 ModuleToProcess 索引鍵值中指定的模組檔案。
請使用這個參數來列出模組所需的所有組件,包括必須載入以更新 FormatsToProcess 或 TypesToProcess 索引鍵中所列之任何格式化檔案或類型檔案的組件,即使這些組件也在 NestedModules 索引鍵中列為二進位模組也一樣。
此參數是 Cmdlet 的必要項,但是 RequiredAssemblies 索引鍵不是資訊清單的必要項。如果省略此參數,且未於出現提示時輸入值,New-ModuleManifest 就會建立值為空陣列的 RequiredAssemblies 索引鍵。</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>RequiredModules</maml:name>
<maml:description>
<maml:para>指定必須位於全域工作階段狀態中的模組。如果所需的模組沒有位於全域工作階段狀態中,嘗試匯入此模組的作業將會失敗。
請以字串形式輸入每個模組名稱,或輸入具有 ModuleName 和 GUID 索引鍵的雜湊表。此雜湊表也可以具有選擇性 ModuleVersion 索引鍵。如需詳細資訊,請參閱範例。
Windows PowerShell 不會自動匯入所需的模組。它只會確認所需的模組是否存在。不過,模組可以包含將所需模組匯入全域工作階段狀態中的指令碼 (.ps1)。
如果省略此參數,New-ModuleManifest 會建立值為空陣列的 RequiredModules 索引鍵。
</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="true">Object[]</command:parameterValue>
<dev:type>
<maml:name>Object[]</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>ScriptsToProcess</maml:name>
<maml:description>
<maml:para>指定匯入模組時要在呼叫者之工作階段狀態中執行的指令碼 (.ps1) 檔案。您可以使用這些指令碼來準備環境,就如同使用登入指令碼一樣。
若要指定在模組之工作階段狀態中執行的指令碼,請使用 NestedModules 索引鍵。
如果省略此參數,New-ModuleManifest 會建立值為空陣列的 ScriptsToProcess 索引鍵。</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="true" variableLength="true" globbing="false" pipelineInput="false" position="named">
<maml:name>TypesToProcess</maml:name>
<maml:description>
<maml:para>指定匯入模組時要執行的類型檔案 (.ps1xml)。
當您匯入模組時,Windows PowerShell 就會使用指定的檔案來執行 Update-TypeData Cmdlet。因為類型檔案沒有限定範圍,所以它們會影響工作階段中的所有工作階段狀態。
此參數是 Cmdlet 的必要項,但是 TypesToProcess 索引鍵不是資訊清單的必要項。如果省略此參數,且未於出現提示時輸入值,New-ModuleManifest 就會建立值為空陣列的 TypesToProcess 索引鍵。</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="true" pipelineInput="false" position="named">
<maml:name>VariablesToExport</maml:name>
<maml:description>
<maml:para>指定模組匯出的變數。允許使用萬用字元。
您可以使用此參數來限制模組所匯出的變數。它可以從已匯出的變數清單中移除變數,但是不能在清單中新增變數。
如果您省略此參數,New-ModuleManifest 就會建立值為 * (全部) 的 VariablesToExport 索引鍵,表示資訊清單將匯出該模組所匯出的所有變數。</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: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.String</maml:name>
<maml:uri />
<maml:description />
</dev:type>
<maml:description>
<maml:para>
<!-- description -->
根據預設,New-ModuleManifest 不會產生任何輸出。不過,如果使用 PassThru 參數,則會產生表示模組資訊清單的 System.String 物件。
</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>
模組資訊清單通常是選擇項。不過,若要匯出安裝在全域組件快取 (GAC) 中的組件,就需要模組資訊清單。
若要在 $pshome\Modules 目錄 (%Windir%\System32\WindowsPowerShell\v1.0\Modules) 中新增或變更檔案,請使用 [以系統管理員身分執行] 選項啟動 Windows PowerShell。
「工作階段」是指 Windows PowerShell 執行環境的執行個體。一個工作階段可以具有一種或多種工作階段狀態。根據預設,雖然一個工作階段只有一種全域工作階段狀態,不過每個匯入的模組都有自己的工作階段狀態。工作階段狀態可讓模組中的命令執行,而不會影響全域工作階段狀態。
「呼叫者的工作階段狀態」是指模組匯入其中的工作階段狀態。一般而言,它代表全域工作階段狀態,不過當模組匯入巢狀模組時,「呼叫者」就是模組而「呼叫者的工作階段狀態」則是模組的工作階段狀態。
</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>
New-ModuleManifest
Path: C:\Users\User01\Documents\WindowsPowerShell\Modules\Test-Module\Test-Module.psd1
NestedModules[0]: BackgroundModule.psm1
Author: Jinghao Liu
CompanyName: Fabrikam, Inc.
Copyright: Copyright © 2009 Liu Jinghao. All rights reserved.
ModuleToProcess: TestModule.psm1
Description: Cmdlets to find common errors in scripts.
TypesToProcess[0]: TestTypes.ps1xml
FormatsToProcess[0]: TestFormat.ps1xml
RequiredAssemblies[0]: Test.dll
FileList[0]: Test-Module.psd1
FileList[1]: Test-Module.psm1
FileList[2]: BackgroundModule.psm1
FileList[3]: TestTypes.ps1xml
FileList[4]: TestFormat.ps1xml
FileList[5]: Test.dll
FileList[6]: TestIcon.ico </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個命令會建立新的模組資訊清單。此 Cmdlet 會提示您指定所需的參數 (包括 Path 參數),並在指定的位置建立資訊清單檔案。
這個命令的輸出顯示提示的回應範例。若要使用預設值,請按 ENTER。
實際的提示,以及其處理加上引號及不加引號之文字的方式,需視執行 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>
-------------------------- 範例 2 --------------------------
</maml:title>
<maml:introduction>
<maml:para>C:\PS></maml:para>
</maml:introduction>
<dev:code>
New-ModuleManifest -PowerShellVersion 1.0 -AliasesToExport JKBC, DRC, TAC </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個命令會建立新的模組資訊清單。此命令包括 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>
-------------------------- 範例 3 --------------------------
</maml:title>
<maml:introduction>
<maml:para>C:\PS></maml:para>
</maml:introduction>
<dev:code>
New-ModuleManifest -RequiredModules FileTransfer,@{ModuleName="BackgroundModule";GUID="486569a2-2784-48bf-af15-70ba837a64d0";ModuleVersion="3.5"} </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>在這個範例中,會示範如何使用 RequiredModules 參數值的字串和雜湊表格式。字串和雜湊表可用於同一個命令中。
這個命令會為需要 FileTransfer 模組的模組以及名為 "BackgroundModule" 的 (虛構) 模組建立模組資訊清單。
此命令會使用字串格式來指定 FileTransfer 模組的名稱,以及使用雜湊表格式來指定 BackgroundModule 的名稱、GUID 和版本。</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=141555</maml:uri>
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Import-Module</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Get-Module</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>New-Module</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Remove-Module</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Export-ModuleMember</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Test-ModuleManifest</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>about_Modules</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>
New-PSSession
</command:name>
<maml:description>
<maml:para>建立與本機或遠端電腦之間的固定連線。</maml:para>
</maml:description>
<maml:copyright>
<maml:para></maml:para>
</maml:copyright>
<command:verb>New</command:verb>
<command:noun>PSSession</command:noun>
<dev:version></dev:version>
</command:details>
<maml:description>
<maml:para>New-PSSession Cmdlet 會在本機或遠端電腦上建立 Windows PowerShell 工作階段 (PSSession)。建立 PSSession 時,Windows PowerShell 會建立與遠端電腦之間的固定連線。
請使用 PSSession 來執行共用資料的多個命令,例如函數或變數的值。若要在 PSSession 中執行命令,請使用 Invoke-Command Cmdlet。若要使用 PSSession 直接與遠端電腦互動,請使用 Enter-PSSession Cmdlet。如需詳細資訊,請參閱 about_PSSessions。
您可以在遠端電腦執行命令,而不需要使用 Enter-PSSession 或 Invoke-Command 的 ComputerName 參數建立 PSSession。使用 ComputerName 參數時,Windows PowerShell 會建立暫時連線,這個連線適用於互動式工作階段或單一命令,而且在工作階段或命令完成之後便會關閉。</maml:para>
</maml:description>
<!-- Cmdlet syntax section-->
<command:syntax>
<command:syntaxItem>
<maml:name>New-PSSession</maml:name>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="true (ByValue, ByPropertyName)" position="1">
<maml:name>ComputerName</maml:name>
<maml:description>
<maml:para>建立與指定之電腦間的固定連線 (PSSession)。如果輸入多個電腦名稱,New-PSSession 會建立多個 PSSession,一部電腦一個。預設為本機電腦。
請輸入一部或多部遠端電腦的 NetBIOS 名稱、IP 位址或完整網域名稱。若要指定本機電腦,請輸入電腦名稱、"localhost" 或點 (.)。當電腦所在的網域與使用者不同時,必須輸入完整網域名稱。您也可以經由管道將電腦名稱 (用引號括住) 輸出至 New-PSSession。
若要在 ComputerName 參數的值中使用 IP 位址,命令必須包含 Credential 參數。而且,該電腦必須設定成 HTTPS 傳輸,或者遠端電腦的 IP 位址必須包含在本機電腦的 WinRM TrustedHosts 清單中。如需將電腦名稱新增到 TrustedHosts 清單的指示,請參閱 about_Remote_Troubleshooting 中的<如何將電腦新增到信任的主機清單>。
注意:在 Windows Vista 和更新版的 Windows 中,若要在 ComputerName 參數值中包含本機電腦,您必須以 [以系統管理員身分執行] 選項啟動 Windows PowerShell。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="true">string[]</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="true (ByPropertyName)" position="named">
<maml:name>ApplicationName</maml:name>
<maml:description>
<maml:para>指定連線 URI 的應用程式名稱區段。當您沒有在命令中使用 ConnectionURI 參數時,可以使用此參數指定應用程式名稱。
預設值為本機電腦上的 $PSSessionApplicationName 喜好設定變數的值。如果沒有定義此喜好設定變數,則預設值為 "WSMAN"。這個值適合大部分使用情況。如需詳細資訊,請參閱 about_Preference_Variables。
WinRM 服務會使用應用程式名稱來選取要服務連線要求的接聽程式。這個參數的值必須符合遠端電腦上接聽程式的 URLPrefix 屬性值。</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>Authentication</maml:name>
<maml:description>
<maml:para>指定用來驗證使用者認證的機制。有效值為 "Default"、"Basic"、"Credssp"、"Digest"、"Kerberos"、"Negotiate" 和 "NegotiateWithImplicitCredential"。預設值為 "Default"。
CredSSP 驗證僅適用於 Windows Vista、Windows Server 2008 和更新版的 Windows。
如需這個參數值的詳細資訊,請參閱 MSDN (Microsoft Developer Network) Library 中的 System.Management.Automation.Runspaces.AuthenticationMechanism 列舉說明,網址為:http://go.microsoft.com/fwlink/?LinkID=144382 (英文)。
警告:認證安全性服務提供者 (CredSSP) 驗證 (其中使用者的認證會傳送到遠端電腦) 是專為需要對一個以上的資源進行驗證的命令所設計,例如存取遠端網路共用。此機制會提高遠端操作的安全性風險。如果遠端電腦已經遭受危害,則傳遞給遠端電腦的認證可能會被用來控制網路工作階段。</maml:para>
</maml:description>
<command:parameterValueGroup>
<command:parameterValue required="false" variableLength="false">Default</command:parameterValue>
<command:parameterValue required="false" variableLength="false">Basic</command:parameterValue>
<command:parameterValue required="false" variableLength="false">Negotiate</command:parameterValue>
<command:parameterValue required="false" variableLength="false">NegotiateWithImplicitCredential</command:parameterValue>
<command:parameterValue required="false" variableLength="false">Credssp</command:parameterValue>
<command:parameterValue required="false" variableLength="false">Digest</command:parameterValue>
<command:parameterValue required="false" variableLength="false">Kerberos</command:parameterValue>
</command:parameterValueGroup>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>CertificateThumbprint</maml:name>
<maml:description>
<maml:para>對於具有執行此動作之權限的使用者帳戶,指定其數位公開金鑰憑證 (X509)。請輸入憑證的憑證指紋。
憑證係在進行用戶端憑證式驗證時使用。這些憑證只能對應到本機使用者帳戶,並不適用於網域帳戶。
若要取得憑證指紋,請在 Windows PowerShell 的 Cert: 磁碟機中使用 Get-Item 或 Get-ChildItem 命令。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">string</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="true (ByPropertyName)" position="named">
<maml:name>ConfigurationName</maml:name>
<maml:description>
<maml:para>指定用於新 PSSession 的工作階段設定。
請輸入工作階段設定的設定名稱或完整資源統一資源識別項 (URI)。如果只指定設定名稱,則會在其前面加上下列結構描述 URI:http://schemas.microsoft.com/powershell。
工作階段的工作階段設定是位於遠端電腦。如果遠端電腦上沒有指定的工作階段設定,則命令會失敗。
預設值為本機電腦上的 $PSSessionConfigurationName 喜好設定變數的值。如果沒有設定此喜好設定變數,則預設值為 Microsoft.PowerShell。如需詳細資訊,請參閱 about_Preference_Variables。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">string</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="true (ByPropertyName)" position="named">
<maml:name>Credential</maml:name>
<maml:description>
<maml:para>指定具有執行此動作之權限的使用者帳戶。預設為目前使用者。
請輸入使用者名稱,例如 "User01"、"Domain01\User01" 或 "User@Domain.com",或是輸入 PSCredential 物件,例如 Get-Credential Cmdlet 傳回的物件。
當您輸入使用者名稱時,會提示您輸入密碼。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">PSCredential</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="false" position="named">
<maml:name>Name</maml:name>
<maml:description>
<maml:para>指定好記的 PSSession 名稱。
您可以在使用其他 Cmdlet (例如 Get-PSSession 和 Enter-PSSession) 時,使用此名稱來表示 PSSession。此名稱不一定要是電腦或目前工作階段的唯一名稱。</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>Port</maml:name>
<maml:description>
<maml:para>指定遠端電腦上要供此命令使用的網路連接埠。預設為連接埠 80 (HTTP 連接埠)。
使用其他連接埠之前,必須先於遠端電腦上設定 WinRM 接聽程式,以接聽該連接埠。請使用下列命令設定接聽程式:
1. winrm delete winrm/config/listener?Address=*+Transport=HTTP
2. winrm create winrm/config/listener?Address=*+Transport=HTTP @{Port=&quot;&lt;連接埠號碼&gt;&quot;}
除非必要,否則請勿使用 Port 參數。命令中的連接埠設定適用於執行命令的所有電腦和工作階段。其他連接埠設定可能會導致無法在所有電腦上執行命令。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">int</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>SessionOption</maml:name>
<maml:description>
<maml:para>設定工作階段的進階選項。請輸入使用 New-PSSessionOption Cmdlet 所建立的 SessionOption 物件。
如果有設定 $PSSessionOption 喜好設定變數的值,它會決定選項的預設值。否則,工作階段會使用系統預設值。
如需工作階段選項 (包括預設值) 的描述,請參閱 New-PSSessionOption。如需 $PSSessionOption 喜好設定變數的詳細資訊,請參閱 about_Preference_Variables。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">PSSessionOption</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>UseSSL</maml:name>
<maml:description>
<maml:para>使用安全通訊端層 (SSL) 通訊協定建立與遠端電腦的連線。預設不會使用 SSL,
因為 WS-Management 會將所有透過網路傳輸的 Windows PowerShell 內容加密。使用 UseSSL 時,便會透過 HTTPS 連線 (而非 HTTP 連線) 傳送資料,提供多一層防護。
如果使用此參數,但是供命令使用的連接埠無法使用 SSL,則命令會失敗。</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>ThrottleLimit</maml:name>
<maml:description>
<maml:para>指定可以建立以執行此命令之同時連線數目的上限。如果您省略這個參數或輸入 0 (零) 這個值,則會使用預設值 32。
節流閥限制只適用於目前的命令,並不適用於工作階段或電腦。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">int</command:parameterValue>
</command:parameter>
</command:syntaxItem>
<command:syntaxItem>
<maml:name>New-PSSession</maml:name>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="true (ByValue, ByPropertyName)" position="1">
<maml:name>Session</maml:name>
<maml:description>
<maml:para>使用指定的 PSSession 做為新 PSSession 的模型。此參數會使用與指定之 PSSession 相同的屬性來建立新的 PSSession。
請輸入包含 PSSession 的變數,或者輸入建立或取得 PSSession 的命令,例如 New-PSSession 或 Get-PSSession 命令。
產生的 PSSession 會與原始 PSSession 具有相同的電腦名稱、應用程式名稱、連線 URI、連接埠、設定名稱、節流閥限制和安全通訊端層 (SSL) 值,但是顯示名稱、識別碼和執行個體識別碼 (GUID) 則不同。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="true">PSSession[]</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="false" position="named">
<maml:name>Name</maml:name>
<maml:description>
<maml:para>指定好記的 PSSession 名稱。
您可以在使用其他 Cmdlet (例如 Get-PSSession 和 Enter-PSSession) 時,使用此名稱來表示 PSSession。此名稱不一定要是電腦或目前工作階段的唯一名稱。</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>ThrottleLimit</maml:name>
<maml:description>
<maml:para>指定可以建立以執行此命令之同時連線數目的上限。如果您省略這個參數或輸入 0 (零) 這個值,則會使用預設值 32。
節流閥限制只適用於目前的命令,並不適用於工作階段或電腦。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">int</command:parameterValue>
</command:parameter>
</command:syntaxItem>
<command:syntaxItem>
<maml:name>New-PSSession</maml:name>
<command:parameter required="true" variableLength="true" globbing="false" pipelineInput="true (ByPropertyName)" position="1">
<maml:name>ConnectionURI</maml:name>
<maml:description>
<maml:para>指定定義連線端點的統一資源識別項 (URI)。此 URI 必須是完整的 URI。
這個字串的格式如下所示:
<傳輸方式>://<電腦名稱>:<連接埠>/<應用程式名稱>
預設值如下所示:
http://localhost:80/WSMAN
URI 中傳輸方式區段的有效值為 HTTP 和 HTTPS。如果未指定 ConnectionURI,就必須使用 UseSSL、ComputerName、Port 和 ApplicationName 參數指定 URI 值。
如果目的電腦將連線重新導向到不同的 URI,那麼除非您在命令中使用 AllowRedirection 參數,否則 Windows PowerShell 不會重新導向連線。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="true">Uri[]</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>AllowRedirection</maml:name>
<maml:description>
<maml:para>允許將這個連線重新導向至替代統一資源識別項 (URI)。
在使用 ConnectionURI 參數時,遠端目的地可能會傳回指示,以重新導向至不同的 URI。根據預設,Windows PowerShell 不會重新導向連線,但是您可以使用 AllowRedirection 參數允許它重新導向連線。
您也可以設定 $PSSessionOption 喜好設定變數的 MaximumConnectionRedirectionCount 屬性或 SessionOption 參數的 MaximumConnectionRedirectionCount 屬性值,藉此限制連線的重新導向次數。
預設值為 5。如需詳細資訊,請參閱 SessionOption 參數的描述以及 New-PSSessionOption。</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>Authentication</maml:name>
<maml:description>
<maml:para>指定用來驗證使用者認證的機制。有效值為 "Default"、"Basic"、"Credssp"、"Digest"、"Kerberos"、"Negotiate" 和 "NegotiateWithImplicitCredential"。預設值為 "Default"。
CredSSP 驗證僅適用於 Windows Vista、Windows Server 2008 和更新版的 Windows。
如需這個參數值的詳細資訊,請參閱 MSDN (Microsoft Developer Network) Library 中的 System.Management.Automation.Runspaces.AuthenticationMechanism 列舉說明,網址為:http://go.microsoft.com/fwlink/?LinkID=144382 (英文)。
警告:認證安全性服務提供者 (CredSSP) 驗證 (其中使用者的認證會傳送到遠端電腦) 是專為需要對一個以上的資源進行驗證的命令所設計,例如存取遠端網路共用。此機制會提高遠端操作的安全性風險。如果遠端電腦已經遭受危害,則傳遞給遠端電腦的認證可能會被用來控制網路工作階段。</maml:para>
</maml:description>
<command:parameterValueGroup>
<command:parameterValue required="false" variableLength="false">Default</command:parameterValue>
<command:parameterValue required="false" variableLength="false">Basic</command:parameterValue>
<command:parameterValue required="false" variableLength="false">Negotiate</command:parameterValue>
<command:parameterValue required="false" variableLength="false">NegotiateWithImplicitCredential</command:parameterValue>
<command:parameterValue required="false" variableLength="false">Credssp</command:parameterValue>
<command:parameterValue required="false" variableLength="false">Digest</command:parameterValue>
<command:parameterValue required="false" variableLength="false">Kerberos</command:parameterValue>
</command:parameterValueGroup>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>CertificateThumbprint</maml:name>
<maml:description>
<maml:para>對於具有執行此動作之權限的使用者帳戶,指定其數位公開金鑰憑證 (X509)。請輸入憑證的憑證指紋。
憑證係在進行用戶端憑證式驗證時使用。這些憑證只能對應到本機使用者帳戶,並不適用於網域帳戶。
若要取得憑證指紋,請在 Windows PowerShell 的 Cert: 磁碟機中使用 Get-Item 或 Get-ChildItem 命令。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">string</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="true (ByPropertyName)" position="named">
<maml:name>ConfigurationName</maml:name>
<maml:description>
<maml:para>指定用於新 PSSession 的工作階段設定。
請輸入工作階段設定的設定名稱或完整資源統一資源識別項 (URI)。如果只指定設定名稱,則會在其前面加上下列結構描述 URI:http://schemas.microsoft.com/powershell。
工作階段的工作階段設定是位於遠端電腦。如果遠端電腦上沒有指定的工作階段設定,則命令會失敗。
預設值為本機電腦上的 $PSSessionConfigurationName 喜好設定變數的值。如果沒有設定此喜好設定變數,則預設值為 Microsoft.PowerShell。如需詳細資訊,請參閱 about_Preference_Variables。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">string</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="true (ByPropertyName)" position="named">
<maml:name>Credential</maml:name>
<maml:description>
<maml:para>指定具有執行此動作之權限的使用者帳戶。預設為目前使用者。
請輸入使用者名稱,例如 "User01"、"Domain01\User01" 或 "User@Domain.com",或是輸入 PSCredential 物件,例如 Get-Credential Cmdlet 傳回的物件。
當您輸入使用者名稱時,會提示您輸入密碼。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">PSCredential</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="false" position="named">
<maml:name>Name</maml:name>
<maml:description>
<maml:para>指定好記的 PSSession 名稱。
您可以在使用其他 Cmdlet (例如 Get-PSSession 和 Enter-PSSession) 時,使用此名稱來表示 PSSession。此名稱不一定要是電腦或目前工作階段的唯一名稱。</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>SessionOption</maml:name>
<maml:description>
<maml:para>設定工作階段的進階選項。請輸入使用 New-PSSessionOption Cmdlet 所建立的 SessionOption 物件。
如果有設定 $PSSessionOption 喜好設定變數的值,它會決定選項的預設值。否則,工作階段會使用系統預設值。
如需工作階段選項 (包括預設值) 的描述,請參閱 New-PSSessionOption。如需 $PSSessionOption 喜好設定變數的詳細資訊,請參閱 about_Preference_Variables。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">PSSessionOption</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>ThrottleLimit</maml:name>
<maml:description>
<maml:para>指定可以建立以執行此命令之同時連線數目的上限。如果您省略這個參數或輸入 0 (零) 這個值,則會使用預設值 32。
節流閥限制只適用於目前的命令,並不適用於工作階段或電腦。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">int</command:parameterValue>
</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>AllowRedirection</maml:name>
<maml:description>
<maml:para>允許將這個連線重新導向至替代統一資源識別項 (URI)。
在使用 ConnectionURI 參數時,遠端目的地可能會傳回指示,以重新導向至不同的 URI。根據預設,Windows PowerShell 不會重新導向連線,但是您可以使用 AllowRedirection 參數允許它重新導向連線。
您也可以設定 $PSSessionOption 喜好設定變數的 MaximumConnectionRedirectionCount 屬性或 SessionOption 參數的 MaximumConnectionRedirectionCount 屬性值,藉此限制連線的重新導向次數。
預設值為 5。如需詳細資訊,請參閱 SessionOption 參數的描述以及 New-PSSessionOption。</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="named">
<maml:name>ApplicationName</maml:name>
<maml:description>
<maml:para>指定連線 URI 的應用程式名稱區段。當您沒有在命令中使用 ConnectionURI 參數時,可以使用此參數指定應用程式名稱。
預設值為本機電腦上的 $PSSessionApplicationName 喜好設定變數的值。如果沒有定義此喜好設定變數,則預設值為 "WSMAN"。這個值適合大部分使用情況。如需詳細資訊,請參閱 about_Preference_Variables。
WinRM 服務會使用應用程式名稱來選取要服務連線要求的接聽程式。這個參數的值必須符合遠端電腦上接聽程式的 URLPrefix 屬性值。</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>WSMAN</dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>Authentication</maml:name>
<maml:description>
<maml:para>指定用來驗證使用者認證的機制。有效值為 "Default"、"Basic"、"Credssp"、"Digest"、"Kerberos"、"Negotiate" 和 "NegotiateWithImplicitCredential"。預設值為 "Default"。
CredSSP 驗證僅適用於 Windows Vista、Windows Server 2008 和更新版的 Windows。
如需這個參數值的詳細資訊,請參閱 MSDN (Microsoft Developer Network) Library 中的 System.Management.Automation.Runspaces.AuthenticationMechanism 列舉說明,網址為:http://go.microsoft.com/fwlink/?LinkID=144382 (英文)。
警告:認證安全性服務提供者 (CredSSP) 驗證 (其中使用者的認證會傳送到遠端電腦) 是專為需要對一個以上的資源進行驗證的命令所設計,例如存取遠端網路共用。此機制會提高遠端操作的安全性風險。如果遠端電腦已經遭受危害,則傳遞給遠端電腦的認證可能會被用來控制網路工作階段。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">AuthenticationMechanism</command:parameterValue>
<dev:type>
<maml:name>AuthenticationMechanism</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>Default</dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>CertificateThumbprint</maml:name>
<maml:description>
<maml:para>對於具有執行此動作之權限的使用者帳戶,指定其數位公開金鑰憑證 (X509)。請輸入憑證的憑證指紋。
憑證係在進行用戶端憑證式驗證時使用。這些憑證只能對應到本機使用者帳戶,並不適用於網域帳戶。
若要取得憑證指紋,請在 Windows PowerShell 的 Cert: 磁碟機中使用 Get-Item 或 Get-ChildItem 命令。</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="true (ByValue, ByPropertyName)" position="1">
<maml:name>ComputerName</maml:name>
<maml:description>
<maml:para>建立與指定之電腦間的固定連線 (PSSession)。如果輸入多個電腦名稱,New-PSSession 會建立多個 PSSession,一部電腦一個。預設為本機電腦。
請輸入一部或多部遠端電腦的 NetBIOS 名稱、IP 位址或完整網域名稱。若要指定本機電腦,請輸入電腦名稱、"localhost" 或點 (.)。當電腦所在的網域與使用者不同時,必須輸入完整網域名稱。您也可以經由管道將電腦名稱 (用引號括住) 輸出至 New-PSSession。
若要在 ComputerName 參數的值中使用 IP 位址,命令必須包含 Credential 參數。而且,該電腦必須設定成 HTTPS 傳輸,或者遠端電腦的 IP 位址必須包含在本機電腦的 WinRM TrustedHosts 清單中。如需將電腦名稱新增到 TrustedHosts 清單的指示,請參閱 about_Remote_Troubleshooting 中的<如何將電腦新增到信任的主機清單>。
注意:在 Windows Vista 和更新版的 Windows 中,若要在 ComputerName 參數值中包含本機電腦,您必須以 [以系統管理員身分執行] 選項啟動 Windows PowerShell。</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="true (ByPropertyName)" position="named">
<maml:name>ConfigurationName</maml:name>
<maml:description>
<maml:para>指定用於新 PSSession 的工作階段設定。
請輸入工作階段設定的設定名稱或完整資源統一資源識別項 (URI)。如果只指定設定名稱,則會在其前面加上下列結構描述 URI:http://schemas.microsoft.com/powershell。
工作階段的工作階段設定是位於遠端電腦。如果遠端電腦上沒有指定的工作階段設定,則命令會失敗。
預設值為本機電腦上的 $PSSessionConfigurationName 喜好設定變數的值。如果沒有設定此喜好設定變數,則預設值為 Microsoft.PowerShell。如需詳細資訊,請參閱 about_Preference_Variables。</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="true" variableLength="true" globbing="false" pipelineInput="true (ByPropertyName)" position="1">
<maml:name>ConnectionURI</maml:name>
<maml:description>
<maml:para>指定定義連線端點的統一資源識別項 (URI)。此 URI 必須是完整的 URI。
這個字串的格式如下所示:
<傳輸方式>://<電腦名稱>:<連接埠>/<應用程式名稱>
預設值如下所示:
http://localhost:80/WSMAN
URI 中傳輸方式區段的有效值為 HTTP 和 HTTPS。如果未指定 ConnectionURI,就必須使用 UseSSL、ComputerName、Port 和 ApplicationName 參數指定 URI 值。
如果目的電腦將連線重新導向到不同的 URI,那麼除非您在命令中使用 AllowRedirection 參數,否則 Windows PowerShell 不會重新導向連線。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="true">Uri[]</command:parameterValue>
<dev:type>
<maml:name>Uri[]</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue></dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="true (ByPropertyName)" position="named">
<maml:name>Credential</maml:name>
<maml:description>
<maml:para>指定具有執行此動作之權限的使用者帳戶。預設為目前使用者。
請輸入使用者名稱,例如 "User01"、"Domain01\User01" 或 "User@Domain.com",或是輸入 PSCredential 物件,例如 Get-Credential Cmdlet 傳回的物件。
當您輸入使用者名稱時,會提示您輸入密碼。</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:parameter required="false" variableLength="true" globbing="false" pipelineInput="false" position="named">
<maml:name>Name</maml:name>
<maml:description>
<maml:para>指定好記的 PSSession 名稱。
您可以在使用其他 Cmdlet (例如 Get-PSSession 和 Enter-PSSession) 時,使用此名稱來表示 PSSession。此名稱不一定要是電腦或目前工作階段的唯一名稱。</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>Port</maml:name>
<maml:description>
<maml:para>指定遠端電腦上要供此命令使用的網路連接埠。預設為連接埠 80 (HTTP 連接埠)。
使用其他連接埠之前,必須先於遠端電腦上設定 WinRM 接聽程式,以接聽該連接埠。請使用下列命令設定接聽程式:
1. winrm delete winrm/config/listener?Address=*+Transport=HTTP
2. winrm create winrm/config/listener?Address=*+Transport=HTTP @{Port=&quot;&lt;連接埠號碼&gt;&quot;}
除非必要,否則請勿使用 Port 參數。命令中的連接埠設定適用於執行命令的所有電腦和工作階段。其他連接埠設定可能會導致無法在所有電腦上執行命令。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">int</command:parameterValue>
<dev:type>
<maml:name>int</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>80</dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="true (ByValue, ByPropertyName)" position="1">
<maml:name>Session</maml:name>
<maml:description>
<maml:para>使用指定的 PSSession 做為新 PSSession 的模型。此參數會使用與指定之 PSSession 相同的屬性來建立新的 PSSession。
請輸入包含 PSSession 的變數,或者輸入建立或取得 PSSession 的命令,例如 New-PSSession 或 Get-PSSession 命令。
產生的 PSSession 會與原始 PSSession 具有相同的電腦名稱、應用程式名稱、連線 URI、連接埠、設定名稱、節流閥限制和安全通訊端層 (SSL) 值,但是顯示名稱、識別碼和執行個體識別碼 (GUID) 則不同。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="true">PSSession[]</command:parameterValue>
<dev:type>
<maml:name>PSSession[]</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>SessionOption</maml:name>
<maml:description>
<maml:para>設定工作階段的進階選項。請輸入使用 New-PSSessionOption Cmdlet 所建立的 SessionOption 物件。
如果有設定 $PSSessionOption 喜好設定變數的值,它會決定選項的預設值。否則,工作階段會使用系統預設值。
如需工作階段選項 (包括預設值) 的描述,請參閱 New-PSSessionOption。如需 $PSSessionOption 喜好設定變數的詳細資訊,請參閱 about_Preference_Variables。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">PSSessionOption</command:parameterValue>
<dev:type>
<maml:name>PSSessionOption</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>ThrottleLimit</maml:name>
<maml:description>
<maml:para>指定可以建立以執行此命令之同時連線數目的上限。如果您省略這個參數或輸入 0 (零) 這個值,則會使用預設值 32。
節流閥限制只適用於目前的命令,並不適用於工作階段或電腦。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">int</command:parameterValue>
<dev:type>
<maml:name>int</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>32</dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>UseSSL</maml:name>
<maml:description>
<maml:para>使用安全通訊端層 (SSL) 通訊協定建立與遠端電腦的連線。預設不會使用 SSL,
因為 WS-Management 會將所有透過網路傳輸的 Windows PowerShell 內容加密。使用 UseSSL 時,便會透過 HTTPS 連線 (而非 HTTP 連線) 傳送資料,提供多一層防護。
如果使用此參數,但是供命令使用的連接埠無法使用 SSL,則命令會失敗。</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:parameters>
<!-- Input - Output section-->
<command:inputTypes>
<command:inputType>
<dev:type>
<maml:name>System.String、System.URI 或 System.Management.Automation.Runspaces.PSSession</maml:name>
<maml:uri />
<maml:description />
</dev:type>
<maml:description>
<maml:para>
<!-- description -->
您可經由管道將 ComputerName (字串)、ConnectionURI (URI) 或 Session (PSSession) 物件輸出至 New-PSSession。
</maml:para>
</maml:description>
</command:inputType>
</command:inputTypes>
<command:returnValues>
<command:returnValue>
<dev:type>
<maml:name>System.Management.Automation.Runspaces.PSSession</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>
此 Cmdlet 會使用 Windows PowerShell 遠端基礎結構。若要使用此 Cmdlet,本機電腦和任何遠端電腦都必須經過設定,以使用 Windows PowerShell 遠端功能。如需詳細資訊,請參閱 about_Remote_Requirements。
在 Windows Vista 和更新版的 Windows 中,若要在本機電腦上建立 PSSession,您必須以 [以系統管理員身分執行] 選項啟動 Windows PowerShell。
當您使用完 PSSession 後,請使用 Remove-PSSession Cmdlet 刪除 PSSession 並釋放其資源。
</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>
$s = new-pssession </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個命令會在本機電腦建立新的 PSSession,並將 PSSession 儲存在 $s 變數中。
您現在可以使用這個 PSSession 在本機電腦執行命令。</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>
$Server01 = new-pssession -ComputerName Server01 </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個命令會在 Server01 電腦建立新的 PSSession,並將其儲存在 $Server01 變數中。
建立多個 PSSession 時,請使用適當的名稱將它們指定給變數。這可協助您在後續的命令中管理 PSSession。</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>
$s1, $s2, $s3 = new-session -computername server1,server2,server3 </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個命令會建立三個新的 PSSession,ComputerName 參數指定的每一部電腦各一個。
這個命令會使用指定運算子 (=),將新的 PSSession 指定給下列變數的陣列:$s1, $s2, $s3。它會將 Server01 PSSession 指定給 $s1、將 Server02 PSSession 指定給 $s2,並將 Server03 PSSession 指定給 $s3。
將多個物件指定給變數的陣列時,Windows PowerShell 會將每個物件分別指定給陣列中的變數。如果物件比變數還要多,所有剩餘的物件都會指定給最後一個變數。如果變數比物件還要多,剩餘的變數就會空白 (null)。</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>
new-pssession -computername Server01 -port 8081 -useSSL -ConfigurationName E12 </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個命令會在 Server01 電腦上建立新的 PSSession,以便連線至伺服器連接埠 8081 及使用 SSL 通訊協定。這個新的 PSSession 會使用名為 "E12" 的其他工作階段設定。
設定連接埠之前,您必須先在遠端電腦上設定要接聽連接埠 8081 的 WinRM 接聽程式。如需詳細資訊,請參閱 Port 參數的描述。</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>
new-pssession -session $s -credential domain01\user01 </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個命令會使用與現有 PSSession 相同的屬性來建立新的 PSSession。當現有 PSSession 的資源已用盡,需要新的 PSSession 來分擔部分需求時,您就可以使用這個命令格式。
這個命令會使用 New-PSSession 的 Session 參數指定儲存在 $s 變數中的 PSSession。它會使用 Domain1\Admin01 使用者的認證來完成命令。</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>
$global:s = new-pssession -computername server1.domain44.corpnet.fabrikam.com -credential domain01\admin01 </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>在這個範例中,會示範如何在不同網域的電腦上,建立具有全域範圍的 PSSession。
根據預設,在命令列建立的 PSSession 都具有本機範圍,而在指令碼中建立的 PSSession 則具有指令碼範圍。
若要建立具有全域範圍的 PSSession,請建立新的 PSSession,然後將 PSSession 儲存在轉換為全域範圍的變數中。在本例中,$ 變數已轉換為全域範圍。
此命令會使用 ComputerName 參數來指定遠端電腦。由於電腦所在的網域與使用者帳戶不同,故同時指定了電腦的完整名稱與使用者的認證。</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>
-------------------------- 範例 7 --------------------------
</maml:title>
<maml:introduction>
<maml:para>C:\PS></maml:para>
</maml:introduction>
<dev:code>
$rs = get-content c:\test\servers.txt | new-PSsession -throttleLimit 50 </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個命令會在 Servers.txt 檔案中列出的每一部電腦 (共 200 部) 上建立 PSSession,並將產生的 PSSession 儲存到 $rs 變數。PSSession 的節流閥限制為 50。
當電腦的名稱儲存成資料庫、試算表、文字檔或其他文字可轉換格式時,您就可以使用這個命令格式。</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>
-------------------------- 範例 8 --------------------------
</maml:title>
<maml:introduction>
<maml:para>C:\PS></maml:para>
</maml:introduction>
<dev:code>
$s = new-PSSession -URI http://Server01:91/NewSession -credential domain01\user01 </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個命令會在 Server01 電腦建立 PSSession,並將其儲存到 $s 變數。它會使用 URI 參數指定傳輸通訊協定、遠端電腦、連接埠和其他工作階段設定。它也會使用 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>
-------------------------- 範例 9 --------------------------
</maml:title>
<maml:introduction>
<maml:para>C:\PS></maml:para>
</maml:introduction>
<dev:code>
$s = new-PSSession -computername (import-csv servers.csv) -credential domain01\admin01 -throttlelimit 16
C:\PS> invoke-command -session $s -scriptblock {get-process powershell} -AsJob </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這些命令會建立一組 PSSession,接著在每個 PSSession 中執行背景工作。
第一個命令會在 Servers.csv 檔案列出的每台電腦建立新的 PSSession。它會使用 New-PSSession Cmdlet 建立 PSSession。ComputerName 參數的值是一個命令,這個命令會使用 Import-Csv Cmdlet 匯入 Servers.csv 檔案並讀取其內容。
這個命令會使用 Credential 參數,利用網域系統管理員的權限來建立 PSSession,並使用 ThrottleLimit 將命令限制為 16 個同時連線。此命令會將 PSSession 儲存在 $s 變數中。
第二個命令會使用 Invoke-Command 的 AsJob 參數啟動背景工作,此工作會對 $s 中的每個 PSSession 執行 "Get-Process PowerShell" 命令。
如需背景工作的詳細資訊,請參閱 about_Jobs 和 about_Remote_Jobs。</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>
-------------------------- 範例 10 --------------------------
</maml:title>
<maml:introduction>
<maml:para>C:\PS></maml:para>
</maml:introduction>
<dev:code>
new-PSSession -ConnectionURI https://management.exchangelabs.com/Management </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個命令會建立新的 PSSession,以便連線到由 URI (而非電腦名稱) 所指定的電腦。</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>
-------------------------- 範例 11 --------------------------
</maml:title>
<maml:introduction>
<maml:para>C:\PS></maml:para>
</maml:introduction>
<dev:code>
$so = New-WSManSessionOption -SkipCACheck
PS C:\> new-pssession -ConnectionUri https://management.exchangelabs.com/Management -SessionOption $so -credential server01\admin01 </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>在這個範例中,會示範如何建立及使用 SessionOption 參數。
第一個命令會使用 New-WSManSessionOption Cmdlet 建立工作階段選項,並會將產生的 SessionOption 物件儲存在 $so 參數中。
第二個命令會在新的工作階段中使用該選項。這個命令會使用 New-PSSession Cmdlet 建立新的工作階段。SessionOption 參數的值是 $so 變數中的 SessionOption 物件。</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=135237</maml:uri>
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>about_PSSessions</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>about_Remote</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Get-PSSession</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Remove-PSSession</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Enter-PSSession</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Exit-PSSession</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Invoke-Command</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>
New-PSSessionOption
</command:name>
<maml:description>
<maml:para>建立包含 PSSession 進階選項的物件。</maml:para>
</maml:description>
<maml:copyright>
<maml:para></maml:para>
</maml:copyright>
<command:verb>New</command:verb>
<command:noun>PSSessionOption</command:noun>
<dev:version></dev:version>
</command:details>
<maml:description>
<maml:para>New-PSSessionOption Cmdlet 會建立包含 PSSession 進階選項的物件。您可以使用此物件當做建立 PSSession 之 Cmdlet (例如 New-PSSession、Enter-PSSession 和 Invoke-Command) 的 SessionOption 參數值。
如果沒有使用參數,New-PSSessionOption 就會產生包含所有選項之預設值的物件。因為所有屬性都可以編輯,所以您可以使用產生的物件當做範本,然後為您的企業建立標準選項物件。</maml:para>
</maml:description>
<!-- Cmdlet syntax section-->
<command:syntax>
<command:syntaxItem>
<maml:name>New-PSSessionOption</maml:name>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>ApplicationArguments</maml:name>
<maml:description>
<maml:para>指定直接傳送至工作階段設定而不進行解譯的雜湊表。工作階段設定可以將這個雜湊表當做 PSSenderInfo 類別的屬性使用。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">PSPrimitiveDictionary</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>CancelTimeOut</maml:name>
<maml:description>
<maml:para>決定 Windows PowerShell 終止取消作業 (CTRL + C) 之前等候此作業完成的時間長度。請輸入以毫秒為單位的值。
預設值為 60000 (一分鐘)。值為 0 (零) 表示沒有逾時,此命令將無限期繼續執行。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">int</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>Culture</maml:name>
<maml:description>
<maml:para>指定 PSSession 所使用的文化特性。請使用 <languagecode2>-<country/regioncode2> 格式來輸入文化特性名稱 (例如 "ja-jP")、包含 CultureInfo 物件的變數,或可取得 CultureInfo 物件的命令 (例如 "get-culture")。
預設值為 $null,而且建立 PSSession 時在作業系統中設定的文化特性將用於此 PSSession 中。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">CultureInfo</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>IdleTimeOut</maml:name>
<maml:description>
<maml:para>決定如果遠端電腦沒有從本機電腦收到任何通訊 (包括活動訊號),PSSession 維持開啟狀態的時間長度。超過此間隔時,PSSession 就會關閉。
請輸入以毫秒為單位的值。預設值為 240000 (4 分鐘)。最小值為 60000 (1 分鐘)。
如果本機和遠端電腦都指定了閒置逾時值,PSSession 就會使用較短的逾時值。本機電腦可以使用這個參數或在 $PSSessionOption 喜好設定變數中設定閒置逾時,藉以設定閒置逾時值。遠端電腦可以在 WS-Management 設定 (WSMAN:\localhost\shell\idletimeout) 中指定閒置逾時值。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">int</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>MaximumReceivedDataSizePerCommand</maml:name>
<maml:description>
<maml:para>指定本機電腦可以從遠端電腦接收單一命令的位元組數目上限。請輸入以位元組為單位的值。根據預設,沒有資料大小限制。
這個選項的設計目的是要保護用戶端電腦的資源。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">int</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>MaximumReceivedObjectSize</maml:name>
<maml:description>
<maml:para>指定本機電腦可以從遠端電腦接收的物件大小上限。請輸入以位元組為單位的值。根據預設,沒有資料大小限制。
這個選項的設計目的是要保護用戶端電腦的資源。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">int</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>MaximumRedirection</maml:name>
<maml:description>
<maml:para>決定連線失敗之前,Windows PowerShell 將連線重新導向至替代統一資源識別項 (URI) 的次數。預設值為 5。值為 0 (零) 會防止所有重新導向。
只有當 AllowRedirection 參數用於建立 PSSession 的命令時,這個選項才會用於 PSSession。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">int</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>NoCompression</maml:name>
<maml:description>
<maml:para>關閉 PSSession 的封包壓縮。雖然壓縮會使用更多處理器循環,不過它會加快傳輸速度。</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>NoEncryption</maml:name>
<maml:description>
<maml:para>關閉資料加密。</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>NoMachineProfile</maml:name>
<maml:description>
<maml:para>防止載入使用者的 Windows 使用者設定檔。因此,雖然 PSSession 的建立速度會更快,不過使用者特定的登錄設定、環境變數等項目以及憑證將無法用於 PSSession 中。</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>OpenTimeOut</maml:name>
<maml:description>
<maml:para>決定用戶端電腦等候系統建立工作階段連線的時間長度。超過此間隔時,建立連線的命令就會失敗。請輸入以毫秒為單位的值。
預設值為 180000 (3 分鐘)。值為 0 (零) 表示沒有逾時,此命令將無限期繼續執行。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">int</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>OperationTimeOut</maml:name>
<maml:description>
<maml:para>決定 PSSession 中任何作業可執行的時間上限。超過此間隔時,作業就會失敗。請輸入以毫秒為單位的值。
預設值為 180000 (3 分鐘)。值為 0 (零) 表示沒有逾時,此作業將無限期繼續執行。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">int</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>ProxyAccessType</maml:name>
<maml:description>
<maml:para>決定用來解析主機名稱的機制。有效的值包括 IEConfig、WinHttpConfig、AutoDetect、NoProxyServer 和 None。預設值為 None。
如需這個參數值的詳細資訊,請參閱 MSDN (Microsoft Developer Network) Library 中的 System.Management.Automation.Remoting.ProxyAccessType 列舉說明,網址為:http://go.microsoft.com/fwlink/?LinkId=144756 (英文)。
</maml:para>
</maml:description>
<command:parameterValueGroup>
<command:parameterValue required="false" variableLength="false">None</command:parameterValue>
<command:parameterValue required="false" variableLength="false">IEConfig</command:parameterValue>
<command:parameterValue required="false" variableLength="false">WinHttpConfig</command:parameterValue>
<command:parameterValue required="false" variableLength="false">AutoDetect</command:parameterValue>
<command:parameterValue required="false" variableLength="false">NoProxyServer</command:parameterValue>
</command:parameterValueGroup>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>ProxyAuthentication</maml:name>
<maml:description>
<maml:para>指定用於 Proxy 解析的驗證方法。有效的值包括 Basic、Digest 和 Negotiate。預設值為 Negotiate。
如需這個參數值的詳細資訊,請參閱 MSDN Library 中的 System.Management.Automation.Runspaces.AuthenticationMechanism 列舉說明,網址為:http://go.microsoft.com/fwlink/?LinkID=144382 (英文)。</maml:para>
</maml:description>
<command:parameterValueGroup>
<command:parameterValue required="false" variableLength="false">Default</command:parameterValue>
<command:parameterValue required="false" variableLength="false">Basic</command:parameterValue>
<command:parameterValue required="false" variableLength="false">Negotiate</command:parameterValue>
<command:parameterValue required="false" variableLength="false">NegotiateWithImplicitCredential</command:parameterValue>
<command:parameterValue required="false" variableLength="false">Credssp</command:parameterValue>
<command:parameterValue required="false" variableLength="false">Digest</command:parameterValue>
<command:parameterValue required="false" variableLength="false">Kerberos</command:parameterValue>
</command:parameterValueGroup>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>ProxyCredential</maml:name>
<maml:description>
<maml:para>指定要用於 Proxy 驗證的認證。請輸入包含 PSCredential 物件的變數或可取得 PSCredential 物件的命令,例如 Get-Credential。如果沒有設定此選項,就不會指定任何認證。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">PSCredential</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>SkipCACheck</maml:name>
<maml:description>
<maml:para>指定透過 HTTPS 進行連線時,用戶端並不會驗證由受信任之憑證授權單位 (CA) 所簽署的伺服器憑證。
請只有在遠端電腦使用其他機制受到信任 (例如,如果遠端電腦屬於實體安全且隔離的網路,或者遠端電腦在 WinRM 設定中是列為信任的主機) 時,才使用此選項。</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>SkipCNCheck</maml:name>
<maml:description>
<maml:para>指定伺服器的憑證一般名稱 (CN) 不需要符合伺服器的主機名稱。這個選項只能用於使用 HTTPS 通訊協定的遠端作業中。
請只針對受信任的電腦使用這個選項。</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>SkipRevocationCheck</maml:name>
<maml:description>
<maml:para>不會驗證伺服器憑證的撤銷狀態。</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>UICulture</maml:name>
<maml:description>
<maml:para>指定 PSSession 所使用的 UI 文化特性。
請使用 <languagecode2>-<country/regioncode2> 格式來輸入文化特性名稱 (例如 "ja-jP")、包含 CultureInfo 物件的變數,或可取得 CultureInfo 物件的命令 (例如 Get-Culture)。
預設值為 $null,而且建立 PSSession 時在作業系統中設定的 UI 文化特性將用於此 PSSession 中。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">CultureInfo</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>UseUTF16</maml:name>
<maml:description>
<maml:para>以 UTF16 格式而非 UTF8 格式編碼要求。</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>ApplicationArguments</maml:name>
<maml:description>
<maml:para>指定直接傳送至工作階段設定而不進行解譯的雜湊表。工作階段設定可以將這個雜湊表當做 PSSenderInfo 類別的屬性使用。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">PSPrimitiveDictionary</command:parameterValue>
<dev:type>
<maml:name>PSPrimitiveDictionary</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>CancelTimeOut</maml:name>
<maml:description>
<maml:para>決定 Windows PowerShell 終止取消作業 (CTRL + C) 之前等候此作業完成的時間長度。請輸入以毫秒為單位的值。
預設值為 60000 (一分鐘)。值為 0 (零) 表示沒有逾時,此命令將無限期繼續執行。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">int</command:parameterValue>
<dev:type>
<maml:name>int</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>60000</dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>Culture</maml:name>
<maml:description>
<maml:para>指定 PSSession 所使用的文化特性。請使用 <languagecode2>-<country/regioncode2> 格式來輸入文化特性名稱 (例如 "ja-jP")、包含 CultureInfo 物件的變數,或可取得 CultureInfo 物件的命令 (例如 "get-culture")。
預設值為 $null,而且建立 PSSession 時在作業系統中設定的文化特性將用於此 PSSession 中。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">CultureInfo</command:parameterValue>
<dev:type>
<maml:name>CultureInfo</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>IdleTimeOut</maml:name>
<maml:description>
<maml:para>決定如果遠端電腦沒有從本機電腦收到任何通訊 (包括活動訊號),PSSession 維持開啟狀態的時間長度。超過此間隔時,PSSession 就會關閉。
請輸入以毫秒為單位的值。預設值為 240000 (4 分鐘)。最小值為 60000 (1 分鐘)。
如果本機和遠端電腦都指定了閒置逾時值,PSSession 就會使用較短的逾時值。本機電腦可以使用這個參數或在 $PSSessionOption 喜好設定變數中設定閒置逾時,藉以設定閒置逾時值。遠端電腦可以在 WS-Management 設定 (WSMAN:\localhost\shell\idletimeout) 中指定閒置逾時值。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">int</command:parameterValue>
<dev:type>
<maml:name>int</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>240000</dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>MaximumReceivedDataSizePerCommand</maml:name>
<maml:description>
<maml:para>指定本機電腦可以從遠端電腦接收單一命令的位元組數目上限。請輸入以位元組為單位的值。根據預設,沒有資料大小限制。
這個選項的設計目的是要保護用戶端電腦的資源。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">int</command:parameterValue>
<dev:type>
<maml:name>int</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>MaximumReceivedObjectSize</maml:name>
<maml:description>
<maml:para>指定本機電腦可以從遠端電腦接收的物件大小上限。請輸入以位元組為單位的值。根據預設,沒有資料大小限制。
這個選項的設計目的是要保護用戶端電腦的資源。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">int</command:parameterValue>
<dev:type>
<maml:name>int</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>MaximumRedirection</maml:name>
<maml:description>
<maml:para>決定連線失敗之前,Windows PowerShell 將連線重新導向至替代統一資源識別項 (URI) 的次數。預設值為 5。值為 0 (零) 會防止所有重新導向。
只有當 AllowRedirection 參數用於建立 PSSession 的命令時,這個選項才會用於 PSSession。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">int</command:parameterValue>
<dev:type>
<maml:name>int</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>5</dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>NoCompression</maml:name>
<maml:description>
<maml:para>關閉 PSSession 的封包壓縮。雖然壓縮會使用更多處理器循環,不過它會加快傳輸速度。</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="false" position="named">
<maml:name>NoEncryption</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>False</dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>NoMachineProfile</maml:name>
<maml:description>
<maml:para>防止載入使用者的 Windows 使用者設定檔。因此,雖然 PSSession 的建立速度會更快,不過使用者特定的登錄設定、環境變數等項目以及憑證將無法用於 PSSession 中。</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="false" position="named">
<maml:name>OpenTimeOut</maml:name>
<maml:description>
<maml:para>決定用戶端電腦等候系統建立工作階段連線的時間長度。超過此間隔時,建立連線的命令就會失敗。請輸入以毫秒為單位的值。
預設值為 180000 (3 分鐘)。值為 0 (零) 表示沒有逾時,此命令將無限期繼續執行。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">int</command:parameterValue>
<dev:type>
<maml:name>int</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>180000</dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>OperationTimeOut</maml:name>
<maml:description>
<maml:para>決定 PSSession 中任何作業可執行的時間上限。超過此間隔時,作業就會失敗。請輸入以毫秒為單位的值。
預設值為 180000 (3 分鐘)。值為 0 (零) 表示沒有逾時,此作業將無限期繼續執行。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">int</command:parameterValue>
<dev:type>
<maml:name>int</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>180000</dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>ProxyAccessType</maml:name>
<maml:description>
<maml:para>決定用來解析主機名稱的機制。有效的值包括 IEConfig、WinHttpConfig、AutoDetect、NoProxyServer 和 None。預設值為 None。
如需這個參數值的詳細資訊,請參閱 MSDN (Microsoft Developer Network) Library 中的 System.Management.Automation.Remoting.ProxyAccessType 列舉說明,網址為:http://go.microsoft.com/fwlink/?LinkId=144756 (英文)。
</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">ProxyAccessType</command:parameterValue>
<dev:type>
<maml:name>ProxyAccessType</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>ProxyAuthentication</maml:name>
<maml:description>
<maml:para>指定用於 Proxy 解析的驗證方法。有效的值包括 Basic、Digest 和 Negotiate。預設值為 Negotiate。
如需這個參數值的詳細資訊,請參閱 MSDN Library 中的 System.Management.Automation.Runspaces.AuthenticationMechanism 列舉說明,網址為:http://go.microsoft.com/fwlink/?LinkID=144382 (英文)。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">AuthenticationMechanism</command:parameterValue>
<dev:type>
<maml:name>AuthenticationMechanism</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>Negotiate</dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>ProxyCredential</maml:name>
<maml:description>
<maml:para>指定要用於 Proxy 驗證的認證。請輸入包含 PSCredential 物件的變數或可取得 PSCredential 物件的命令,例如 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:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>SkipCACheck</maml:name>
<maml:description>
<maml:para>指定透過 HTTPS 進行連線時,用戶端並不會驗證由受信任之憑證授權單位 (CA) 所簽署的伺服器憑證。
請只有在遠端電腦使用其他機制受到信任 (例如,如果遠端電腦屬於實體安全且隔離的網路,或者遠端電腦在 WinRM 設定中是列為信任的主機) 時,才使用此選項。</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="false" position="named">
<maml:name>SkipCNCheck</maml:name>
<maml:description>
<maml:para>指定伺服器的憑證一般名稱 (CN) 不需要符合伺服器的主機名稱。這個選項只能用於使用 HTTPS 通訊協定的遠端作業中。
請只針對受信任的電腦使用這個選項。</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="false" position="named">
<maml:name>SkipRevocationCheck</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>False</dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>UICulture</maml:name>
<maml:description>
<maml:para>指定 PSSession 所使用的 UI 文化特性。
請使用 <languagecode2>-<country/regioncode2> 格式來輸入文化特性名稱 (例如 "ja-jP")、包含 CultureInfo 物件的變數,或可取得 CultureInfo 物件的命令 (例如 Get-Culture)。
預設值為 $null,而且建立 PSSession 時在作業系統中設定的 UI 文化特性將用於此 PSSession 中。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">CultureInfo</command:parameterValue>
<dev:type>
<maml:name>CultureInfo</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>目前的 UI 文化特性</dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>UseUTF16</maml:name>
<maml:description>
<maml:para>以 UTF16 格式而非 UTF8 格式編碼要求。</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 (UTF8 編碼)</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.Remoting.PSSessionOption</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>
如果 SessionOption 參數沒有用於建立 PSSession 的命令中,工作階段選項會由 $PSSessionOption 喜好設定變數的屬性值所決定 (如果有設定的話)。如需 $PSSessionOption 變數的詳細資訊,請參閱 about_Preference_Variables。
</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>
New-PSSessionOption
MaximumConnectionRedirectionCount : 5
NoCompression : False
NoMachineProfile : False
ProxyAccessType : IEConfig
ProxyAuthentication : Negotiate
ProxyCredential :
SkipCACheck : False
SkipCNCheck : False
SkipRevocationCheck : False
OperationTimeout : 00:03:00
NoEncryption : False
UseUTF16 : False
Culture :
UICulture :
MaximumReceivedDataSizePerCommand :
MaximumReceivedObjectSize :
ApplicationArguments :
OpenTimeout : 00:03:00
CancelTimeout : 00:01:00
IdleTimeout : 00:04:00 </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>
$pso = new-pssessionoption -Culture "fr-fr" -MaximumReceivedObjectSize 10MB
C:\PS> new-pssession -computerName Server01 -SessionOption $pso </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個範例會示範如何使用工作階段選項物件來設定工作階段。
第一個命令會建立新的工作階段選項物件,並將它儲存在 $pso 變數的值中。
第二個命令會使用 New-PSSession Cmdlet,在 Server01 遠端電腦上建立 PSSession。此命令會使用 $pso 變數值中的工作階段選項物件做為命令之 SessionOption 參數的值。
</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>
enter-pssession -computername Server01 -sessionOption (new-pssessionoption -noEncryption -noCompression) </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個命令會使用 Enter-PSSession Cmdlet,啟動與 Server01 電腦之間的互動式工作階段。SessionOption 參數的值是具有 NoEncryption 和 NoCompression 切換參數的 New-PSSessionOption 命令。
以括號括住 New-PSSessionOption 命令,可確保它會在 Enter-PSSession 命令之前執行。</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>
$a = new-pssessionoption
MaximumConnectionRedirectionCount : 5
NoCompression : False
NoMachineProfile : False
ProxyAccessType : IEConfig
ProxyAuthentication : Negotiate
ProxyCredential :
SkipCACheck : False
SkipCNCheck : False
SkipRevocationCheck : False
OperationTimeout : 00:03:00
NoEncryption : False
UseUTF16 : False
Culture :
UICulture :
MaximumReceivedDataSizePerCommand :
MaximumReceivedObjectSize :
ApplicationArguments :
OpenTimeout : 00:03:00
CancelTimeout : 00:01:00
IdleTimeout : 00:04:00
C:\PS> $a.UICulture = (get-UICulture)
C:\PS> $a.OpenTimeout = (new-timespan -minutes 4)
C:\PS> $a.MaximumConnectionRedirectionCount = 1
C:\PS> $a
MaximumConnectionRedirectionCount : 1
NoCompression : False
NoMachineProfile : False
ProxyAccessType : IEConfig
ProxyAuthentication : Negotiate
ProxyCredential :
SkipCACheck : False
SkipCNCheck : False
SkipRevocationCheck : False
OperationTimeout : 00:03:00
NoEncryption : False
UseUTF16 : False
Culture :
UICulture : en-US
MaximumReceivedDataSizePerCommand :
MaximumReceivedObjectSize :
ApplicationArguments :
OpenTimeout : 00:04:00
CancelTimeout : 00:01:00
IdleTimeout : 00:04:00 </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>
-------------------------- 範例 5 --------------------------
</maml:title>
<maml:introduction>
<maml:para>C:\PS></maml:para>
</maml:introduction>
<dev:code>
$PSSessionOption = New-PSSessionOption -OpenTimeOut 120000 </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個命令會建立 $PSSessionOption 喜好設定變數。
當工作階段中存在 $PSSessionOption 喜好設定變數時,它會針對使用 New-PSSession、Enter-PSSession 和 Invoke-Command Cmdlet 所建立之 PSSession 的選項建立預設值。
若要讓 $PSSessionOption 變數可用於所有工作階段,請將它新增至 Windows PowerShell 工作階段和您的 Windows PowerShell 設定檔。
如需 $PSSessionOption 變數的詳細資訊,請參閱 about_Preference_Variables。如需設定檔的詳細資訊,請參閱 about_Profiles。</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>
$skipCN = new-pssessionoption -SkipCNCheck
C:\PS> new-pssession -computername 171.09.21.207 -UseSSL -credential domain01\user01 -sessionOption $skipCN </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個範例會示範如何使用 SessionOption 物件來滿足遠端工作階段設定的需求。
第一個命令會使用 New-PSSessionOption Cmdlet 來建立具有 SkipCNCheck 屬性的工作階段選項物件。此命令會將產生的工作階段物件儲存在 $skipCN 變數中。
第二個命令會使用 New-PSSession Cmdlet,在遠端電腦上建立新的 PSSession。$skipCN 檢查變數會用於 SessionOption 參數的值。
因為電腦是依照 IP 位址加以識別,所以 ComputerName 參數的值不會符合憑證中用於安全通訊端層 (SSL) 的任何一般名稱。因此,需要使用 SkipCNCheck 選項。</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=144305</maml:uri>
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Enter-PSSession</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>New-PSSession</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Invoke-Command</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>
Receive-Job
</command:name>
<maml:description>
<maml:para>取得目前工作階段中 Windows PowerShell 背景工作的結果。</maml:para>
</maml:description>
<maml:copyright>
<maml:para></maml:para>
</maml:copyright>
<command:verb>Receive</command:verb>
<command:noun>Job</command:noun>
<dev:version></dev:version>
</command:details>
<maml:description>
<maml:para>Receive-Job Cmdlet 會取得 Windows PowerShell 背景工作的結果。請使用 Receive-Job 取得使用 Start-Job Cmdlet 或是任何 Cmdlet 的 AsJob 參數所啟動之工作的結果。您可以依工作的名稱、識別碼、執行個體識別碼、電腦名稱、位置或工作階段,或是透過提交工作物件的方式,取得所有工作的結果或識別工作。
當您啟動 Windows PowerShell 背景工作時,工作隨即啟動,但是結果並不會立即出現。事實上,命令會傳回表示背景工作的物件。工作物件包含有用的工作資訊,但不包含結果。這個方法可讓您在工作執行時,繼續在工作階段中執行作業。如需 Windows PowerShell 中背景工作的詳細資訊,請參閱 about_Jobs。
若要取得命令的結果,請使用 Receive-Job Cmdlet。Receive-Job 會取得截至提交 Receive-Job 命令時,已經產生的結果。如果結果還不完整,您可以執行額外的 Receive-Job 命令,取得剩餘的結果。
根據預設,工作結果在接收後便會從系統刪除,但是您可以使用 Keep 參數儲存結果,以便重新接收結果。若要刪除工作結果,請重新接收結果 (不指定 Keep 參數)、關閉工作階段,或是使用 Remove-Job Cmdlet 刪除工作階段中的工作。</maml:para>
</maml:description>
<!-- Cmdlet syntax section-->
<command:syntax>
<command:syntaxItem>
<maml:name>Receive-Job</maml:name>
<command:parameter required="true" variableLength="true" globbing="false" pipelineInput="true (ByValue, ByPropertyName)" position="1">
<maml:name>Job</maml:name>
<maml:description>
<maml:para>指定要擷取其結果的工作。此參數為 Receive-Job 命令的必要項。請輸入包含工作的變數或可取得工作的命令。您也可以經由管道將工作物件輸出至 Receive-Job。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="true">Job[]</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="true (ByPropertyName)" position="2">
<maml:name>ComputerName</maml:name>
<maml:description>
<maml:para>取得在指定電腦執行之工作的結果。請輸入電腦名稱。預設為目前工作階段中的所有工作。
此參數會從儲存在本機電腦的工作結果進行選擇,而不會從遠端電腦取得資料。若要取得儲存在遠端電腦的工作結果,請使用 Invoke-Command Cmdlet 從遠端執行 Receive-Job 命令。
</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>Keep</maml:name>
<maml:description>
<maml:para>將工作結果儲存於系統中,即使在您已經接收工作結果後也是如此。在擷取工作結果後,預設會刪除工作結果。
若要刪除結果,請重新使用 Receive-Job 而不指定 Keep 參數來接收結果、關閉工作階段,或是使用 Remove-Job Cmdlet 刪除工作階段中的工作。</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>NoRecurse</maml:name>
<maml:description>
<maml:para>只從指定的工作中取得結果。根據預設,Receive-Job 也會取得所指定工作之所有子工作的結果。</maml:para>
</maml:description>
</command:parameter>
</command:syntaxItem>
<command:syntaxItem>
<maml:name>Receive-Job</maml:name>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="true (ByPropertyName)" position="1">
<maml:name>InstanceId</maml:name>
<maml:description>
<maml:para>取得具有所指定執行個體識別碼之工作的結果。預設為目前工作階段中的所有工作。
執行個體識別碼是一種 GUID,它能夠唯一識別電腦上的工作。若要尋找工作的執行個體識別碼,請使用 Get-Job Cmdlet。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="true">Guid[]</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>Keep</maml:name>
<maml:description>
<maml:para>將工作結果儲存於系統中,即使在您已經接收工作結果後也是如此。在擷取工作結果後,預設會刪除工作結果。
若要刪除結果,請重新使用 Receive-Job 而不指定 Keep 參數來接收結果、關閉工作階段,或是使用 Remove-Job Cmdlet 刪除工作階段中的工作。</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>NoRecurse</maml:name>
<maml:description>
<maml:para>只從指定的工作中取得結果。根據預設,Receive-Job 也會取得所指定工作之所有子工作的結果。</maml:para>
</maml:description>
</command:parameter>
</command:syntaxItem>
<command:syntaxItem>
<maml:name>Receive-Job</maml:name>
<command:parameter required="true" variableLength="true" globbing="false" pipelineInput="true (ByValue, ByPropertyName)" position="1">
<maml:name>Job</maml:name>
<maml:description>
<maml:para>指定要擷取其結果的工作。此參數為 Receive-Job 命令的必要項。請輸入包含工作的變數或可取得工作的命令。您也可以經由管道將工作物件輸出至 Receive-Job。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="true">Job[]</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="true (ByPropertyName)" position="2">
<maml:name>Location</maml:name>
<maml:description>
<maml:para>只取得具有所指定位置之工作的結果。預設為目前工作階段中的所有工作。</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>Keep</maml:name>
<maml:description>
<maml:para>將工作結果儲存於系統中,即使在您已經接收工作結果後也是如此。在擷取工作結果後,預設會刪除工作結果。
若要刪除結果,請重新使用 Receive-Job 而不指定 Keep 參數來接收結果、關閉工作階段,或是使用 Remove-Job Cmdlet 刪除工作階段中的工作。</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>NoRecurse</maml:name>
<maml:description>
<maml:para>只從指定的工作中取得結果。根據預設,Receive-Job 也會取得所指定工作之所有子工作的結果。</maml:para>
</maml:description>
</command:parameter>
</command:syntaxItem>
<command:syntaxItem>
<maml:name>Receive-Job</maml:name>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="true (ByPropertyName)" position="1">
<maml:name>Name</maml:name>
<maml:description>
<maml:para>取得具有所指定好記名稱之工作的結果。預設為目前工作階段中的所有工作。</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>Keep</maml:name>
<maml:description>
<maml:para>將工作結果儲存於系統中,即使在您已經接收工作結果後也是如此。在擷取工作結果後,預設會刪除工作結果。
若要刪除結果,請重新使用 Receive-Job 而不指定 Keep 參數來接收結果、關閉工作階段,或是使用 Remove-Job Cmdlet 刪除工作階段中的工作。</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>NoRecurse</maml:name>
<maml:description>
<maml:para>只從指定的工作中取得結果。根據預設,Receive-Job 也會取得所指定工作之所有子工作的結果。</maml:para>
</maml:description>
</command:parameter>
</command:syntaxItem>
<command:syntaxItem>
<maml:name>Receive-Job</maml:name>
<command:parameter required="true" variableLength="true" globbing="false" pipelineInput="true (ByValue, ByPropertyName)" position="1">
<maml:name>Job</maml:name>
<maml:description>
<maml:para>指定要擷取其結果的工作。此參數為 Receive-Job 命令的必要項。請輸入包含工作的變數或可取得工作的命令。您也可以經由管道將工作物件輸出至 Receive-Job。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="true">Job[]</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="true (ByPropertyName)" position="2">
<maml:name>Session</maml:name>
<maml:description>
<maml:para>取得在指定之 Windows PowerShell 工作階段 (PSSession) 執行之工作的結果。請輸入包含 PSSession 的變數或可取得 PSSession 的命令,例如 Get-PSSession 命令。預設為目前工作階段中的所有工作。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="true">PSSession[]</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>Keep</maml:name>
<maml:description>
<maml:para>將工作結果儲存於系統中,即使在您已經接收工作結果後也是如此。在擷取工作結果後,預設會刪除工作結果。
若要刪除結果,請重新使用 Receive-Job 而不指定 Keep 參數來接收結果、關閉工作階段,或是使用 Remove-Job Cmdlet 刪除工作階段中的工作。</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>NoRecurse</maml:name>
<maml:description>
<maml:para>只從指定的工作中取得結果。根據預設,Receive-Job 也會取得所指定工作之所有子工作的結果。</maml:para>
</maml:description>
</command:parameter>
</command:syntaxItem>
<command:syntaxItem>
<maml:name>Receive-Job</maml:name>
<command:parameter required="true" variableLength="true" globbing="false" pipelineInput="true (ByPropertyName)" position="1">
<maml:name>Id</maml:name>
<maml:description>
<maml:para>取得具有所指定識別碼之工作的結果。預設為目前工作階段中的所有工作。
識別碼是整數,可唯一識別目前工作階段內的工作。它比執行個體識別碼更容易記得和輸入,但是只有在目前的工作階段中才具有唯一性。您可以輸入一個或多個識別碼 (以逗號分隔)。若要尋找工作的識別碼,請輸入 "Get-Job" 且不要指定參數。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="true">Int32[]</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>Keep</maml:name>
<maml:description>
<maml:para>將工作結果儲存於系統中,即使在您已經接收工作結果後也是如此。在擷取工作結果後,預設會刪除工作結果。
若要刪除結果,請重新使用 Receive-Job 而不指定 Keep 參數來接收結果、關閉工作階段,或是使用 Remove-Job Cmdlet 刪除工作階段中的工作。</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>NoRecurse</maml:name>
<maml:description>
<maml:para>只從指定的工作中取得結果。根據預設,Receive-Job 也會取得所指定工作之所有子工作的結果。</maml:para>
</maml:description>
</command:parameter>
</command:syntaxItem>
</command:syntax>
<!-- Cmdlet parameter section -->
<command:parameters>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="true (ByPropertyName)" position="2">
<maml:name>ComputerName</maml:name>
<maml:description>
<maml:para>取得在指定電腦執行之工作的結果。請輸入電腦名稱。預設為目前工作階段中的所有工作。
此參數會從儲存在本機電腦的工作結果進行選擇,而不會從遠端電腦取得資料。若要取得儲存在遠端電腦的工作結果,請使用 Invoke-Command Cmdlet 從遠端執行 Receive-Job 命令。
</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="true" variableLength="true" globbing="false" pipelineInput="true (ByPropertyName)" position="1">
<maml:name>Id</maml:name>
<maml:description>
<maml:para>取得具有所指定識別碼之工作的結果。預設為目前工作階段中的所有工作。
識別碼是整數,可唯一識別目前工作階段內的工作。它比執行個體識別碼更容易記得和輸入,但是只有在目前的工作階段中才具有唯一性。您可以輸入一個或多個識別碼 (以逗號分隔)。若要尋找工作的識別碼,請輸入 "Get-Job" 且不要指定參數。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="true">Int32[]</command:parameterValue>
<dev:type>
<maml:name>Int32[]</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue></dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="true (ByPropertyName)" position="1">
<maml:name>InstanceId</maml:name>
<maml:description>
<maml:para>取得具有所指定執行個體識別碼之工作的結果。預設為目前工作階段中的所有工作。
執行個體識別碼是一種 GUID,它能夠唯一識別電腦上的工作。若要尋找工作的執行個體識別碼,請使用 Get-Job Cmdlet。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="true">Guid[]</command:parameterValue>
<dev:type>
<maml:name>Guid[]</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>Job</maml:name>
<maml:description>
<maml:para>指定要擷取其結果的工作。此參數為 Receive-Job 命令的必要項。請輸入包含工作的變數或可取得工作的命令。您也可以經由管道將工作物件輸出至 Receive-Job。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="true">Job[]</command:parameterValue>
<dev:type>
<maml:name>Job[]</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>Keep</maml:name>
<maml:description>
<maml:para>將工作結果儲存於系統中,即使在您已經接收工作結果後也是如此。在擷取工作結果後,預設會刪除工作結果。
若要刪除結果,請重新使用 Receive-Job 而不指定 Keep 參數來接收結果、關閉工作階段,或是使用 Remove-Job 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="true" globbing="false" pipelineInput="true (ByPropertyName)" position="2">
<maml:name>Location</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="true" globbing="false" pipelineInput="true (ByPropertyName)" position="1">
<maml:name>Name</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>NoRecurse</maml:name>
<maml:description>
<maml:para>只從指定的工作中取得結果。根據預設,Receive-Job 也會取得所指定工作之所有子工作的結果。</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="true (ByPropertyName)" position="2">
<maml:name>Session</maml:name>
<maml:description>
<maml:para>取得在指定之 Windows PowerShell 工作階段 (PSSession) 執行之工作的結果。請輸入包含 PSSession 的變數或可取得 PSSession 的命令,例如 Get-PSSession 命令。預設為目前工作階段中的所有工作。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="true">PSSession[]</command:parameterValue>
<dev:type>
<maml:name>PSSession[]</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.Management.Automation.Job</maml:name>
<maml:uri />
<maml:description />
</dev:type>
<maml:description>
<maml:para>
<!-- description -->
您可以經由管道將工作物件輸出至 Receive-Job。
</maml:para>
</maml:description>
</command:inputType>
</command:inputTypes>
<command:returnValues>
<command:returnValue>
<dev:type>
<maml:name>PSObject</maml:name>
<maml:uri />
<maml:description />
</dev:type>
<maml:description>
<maml:para>
<!-- description -->
Receive-Job 會傳回工作中命令的結果。
</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>
$job = start-job -scriptblock {get-process}
C:\PS> receive-job -job $job </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這些命令會使用 Job 參數取得特定工作的結果。第一個命令會使用 Start-Job Cmdlet,啟動執行 "Get-Process" 命令的工作。這個命令會使用指定運算子 (=),將產生的工作物件儲存在 $job 變數中。
第二個命令會使用 Receive-Job Cmdlet 取得工作結果,並使用 Job 參數指定工作。</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>
$job = start-job -scriptblock {get-process}
C:\PS> $job | receive-job </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個範例與範例 2 相同,唯一的不同是這個命令會使用管線運算子 (|),將工作物件傳送給 Receive-Job。因此,這個命令並不需要使用 Job 參數指定工作。</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>
$j = invoke-command -computername Server01, Server02, Server03 -scriptblock {get-service} -AsJob
C:\PS> $j.childjobs
Id Name State HasMoreData Location Command
-- ---- ----- ----------- -------- -------
2 Job2 Completed True Server01 get-service
3 Job3 Completed True Server02 get-service
4 Job4 Completed True Server03 get-service
C:\PS> receive-job -name Job3 -keep
Status Name DisplayName PSComputerName
------ ----------- ----------- --------------
Running AeLookupSvc Application Experience Server02
Stopped ALG Application Layer Gateway Service Server02
Running Appinfo Application Information Server02
Running AppMgmt Application Management Server02 </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這些命令會使用 Receive-Job 的 Name 參數,取得在遠端電腦上執行之其中一個背景工作的結果。
第一個命令會使用 Invoke-Command Cmdlet 啟動在三部遠端電腦執行 Get-Service 命令的背景工作。這個命令會使用 AsJob 參數,將命令當做背景工作來執行,並將產生的工作物件儲存在 $j 變數中。
使用 Invoke-Command 的 AsJob 參數啟動工作時,即使工作是在遠端電腦執行,仍會在本機電腦建立工作物件。因此,請使用本機命令來管理工作。
此外,當您使用 AsJob 時,Windows PowerShell 也會傳回一個工作物件,其中包含已啟動之每項工作的子工作。在本例中,工作物件包含三項子工作,每部遠端電腦的每一項工作各一項子工作。
第二個命令會使用點標記法,顯示 $j 中工作物件的 ChildJobs 屬性值。顯示中列出此命令建立的三項子工作,每部遠端電腦的工作各一項子工作。
第三個命令會使用 Receive-Job Cmdlet 取得在 Server02 電腦執行之 Job3 子工作的結果。這個命令會使用 Name 參數指定子工作的名稱,並使用 Keep 參數儲存工作結果 (即使已經接收過工作結果也一樣)。</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>
$s = new-pssession -computername Server01, Server02, Server03
C:\PS> $j = invoke-command -session $s -scriptblock {start-job -scriptblock {get-eventlog -logname system}}
C:\PS> $j
Id Name State HasMoreData Location Command
-- ---- ----- ----------- -------- -------
1 Job1 Completed True Localhost get-eventlog system
2 Job2 Completed True Localhost get-eventlog system
3 Job3 Completed True Localhost get-eventlog system
C:\PS> $results = invoke-command -session $s -scriptblock {param($j) receive-job -job $j} -ArgumentList $j </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個範例會示範如何取得在三部遠端電腦上執行之背景工作的結果。
第一個命令會使用 New-PSSession Cmdlet 建立三個 PSSession (在命令中指定的每部伺服器各建立一個),並將這些 PSSession 儲存在 $s 變數中。
第二個命令會使用 Invoke-Command Cmdlet,對 $s 變數中的每個 PSSession 執行 Start-Job 命令。該工作會執行 Get-Eventlog 命令,以取得系統記錄檔中的事件。這個命令會將結果儲存在 $j 變數中。
由於這個命令是使用 Invoke-Command 來執行 Start-Job 命令,因此它實際上是在這三部電腦上分別啟動三個獨立的工作。因此,這個命令便傳回三個工作物件,代表在三部不同電腦上,以本機方式執行的三項工作。
第三個命令會顯示 $j 中三個工作物件。
第四個命令會使用 Invoke-Command,在 $s 的每個 PSSession 中執行 Receive-Job 命令並將結果儲存在 $results 變數中。
因為 $j 是本機變數,所以指令碼區塊會使用 "param" 關鍵字在命令中宣告變數,並使用 ArgumentList 參數來提供 $j 的值。</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=113372</maml:uri>
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>about_Jobs</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>about_Job_Details</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>about_Remote_Jobs</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Start-Job</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Get-Job</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Wait-Job</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Stop-Job</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Remove-Job</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Invoke-Command</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>
Register-PSSessionConfiguration
</command:name>
<maml:description>
<maml:para>建立並註冊新的工作階段設定。</maml:para>
</maml:description>
<maml:copyright>
<maml:para></maml:para>
</maml:copyright>
<command:verb>Register</command:verb>
<command:noun>PSSessionConfiguration</command:noun>
<dev:version></dev:version>
</command:details>
<maml:description>
<maml:para>Register-PSSessionConfiguration Cmdlet 會在本機電腦上建立並註冊新的工作階段設定。這是進階的 Cmdlet,適合系統管理員用來管理使用者的自訂工作階段設定。
每個 Windows PowerShell 遠端工作階段都會使用工作階段設定。當使用者建立連線到電腦的工作階段時,他們就可以選取設定或使用啟用 Windows PowerShell 遠端功能時所註冊的預設設定。此外,使用者也可以設定 $PSSessionConfigurationName 喜好設定變數,以便針對目前工作階段中建立的工作階段指定預設設定。
工作階段設定會設定工作階段的環境。您可以使用實作新設定類別的組件以及使用在工作階段中執行的指令碼,藉以定義此設定。此設定會決定哪些命令可用於工作階段中,而且它可以包含保護電腦的設定,例如限制工作階段可以從遠端接收單一物件或命令之資料量的設定。您也可以指定決定使用該設定所需權限的安全性描述元。</maml:para>
</maml:description>
<!-- Cmdlet syntax section-->
<command:syntax>
<command:syntaxItem>
<maml:name>Register-PSSessionConfiguration</maml:name>
<command:parameter required="true" variableLength="false" globbing="false" pipelineInput="false" position="2">
<maml:name>AssemblyName</maml:name>
<maml:description>
<maml:para>指定定義設定類型之組件檔案 (*.dll) 的名稱。您可以在這個參數或 ApplicationBase 參數的值中指定 .dll 的路徑。
指定 ConfigurationTypeName 參數時,此參數為必要項。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">string</command:parameterValue>
</command:parameter>
<command:parameter required="true" variableLength="false" globbing="false" pipelineInput="false" position="3">
<maml:name>ConfigurationTypeName</maml:name>
<maml:description>
<maml:para>指定用於此設定之 Microsoft .NET Framework 型別的完整名稱。您所指定的類型必須實作 System.Management.Automation.Remoting.PSSessionConfiguration 類別。
若要指定實作設定類型的組件檔案 (.dll),請使用 AssemblyName 和 AssemblyBase 參數。
建立類型可讓您控制更多工作階段設定的層面,例如公開或隱藏 Cmdlet 的特定參數,或是設定使用者無法覆寫的資料大小和物件大小限制。
如果您省略此參數,DefaultRemotePowerShellConfiguration 類別就會用於工作階段設定。</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>ApplicationBase</maml:name>
<maml:description>
<maml:para>指定 AssemblyName 參數值中指定之組件檔案 (*.dll) 的路徑。當 AssemblyName 參數的值沒有包含路徑時,請使用此參數。預設值為目前目錄。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">string</command:parameterValue>
</command:parameter>
<command:parameter required="true" variableLength="false" globbing="false" pipelineInput="false" position="1">
<maml:name>Name</maml:name>
<maml:description>
<maml:para>指定工作階段設定的名稱。此參數為必要項。</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>Force</maml:name>
<maml:description>
<maml:para>抑制所有使用者提示,並重新啟動 WinRM 服務,而不進行提示。重新啟動服務可讓設定變更生效。
若要防止進行重新啟動並抑制重新啟動的提示,請使用 NoServiceRestart 參數。</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>MaximumReceivedDataSizePerCommandMB</maml:name>
<maml:description>
<maml:para>限制可在任何單一遠端命令中傳送至這部電腦的資料量。請輸入以 MB 為單位的資料大小。預設值為 50 MB。
如果資料大小限制定義於 ConfigurationTypeName 參數所指定的設定類型中,系統就會使用設定類型中的限制而忽略這個參數的值。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">double</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>MaximumReceivedObjectSizeMB</maml:name>
<maml:description>
<maml:para>限制可在任何單一物件中傳送至這部電腦的資料量。請輸入以 MB 為單位的資料大小。預設值為 10 MB。
如果物件大小限制定義於 ConfigurationTypeName 參數所指定的設定類型中,系統就會使用設定類型中的限制而忽略這個參數的值。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">double</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>NoServiceRestart</maml:name>
<maml:description>
<maml:para>不重新啟動 WinRM 服務,並抑制重新啟動服務的提示。
根據預設,當您輸入 Register-PSSessionConfiguration 命令時,系統就會提示您重新啟動 WinRM 服務,讓新的工作階段設定生效。在重新啟動 WinRM 服務之前,新的工作階段設定不會生效。
若要重新啟動 WinRM 服務而不進行提示,請使用 Force 參數。若要手動重新啟動 WinRM 服務,請使用 Restart-Service Cmdlet。</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>ProcessorArchitecture</maml:name>
<maml:description>
<maml:para>指定設定的處理器架構。這個值會決定使用此設定時,系統將啟動裝載 Windows PowerShell 的 32 位元或 64 位元版本處理序。有效的值包括 x86、AMD64 和 IA64。
預設值是由裝載工作階段設定之電腦的處理器架構所決定。</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>SecurityDescriptorSDDL</maml:name>
<maml:description>
<maml:para>指定設定的安全性描述元定義語言 (SDDL) 字串。
這個字串會決定使用新工作階段設定所需的權限。若要在工作階段中使用工作階段設定,使用者至少必須擁有該設定的 "Execute(Invoke)" 權限。
如果安全性描述元很複雜,請考慮使用 ShowSecurityDescriptorUI 參數而非這個參數。您無法在同一個命令中使用這兩個參數。
如果您省略此參數,WinRM 服務的根 SDDL 就會用於這項設定。若要檢視或變更根 SDDL,請使用 WS-Management 提供者,例如 "get-item wsman:\localhost\service\rootSDDL"。如需 WS-Management 提供者的詳細資訊,請輸入 "get-help wsman"。</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>ShowSecurityDescriptorUI</maml:name>
<maml:description>
<maml:para>顯示可協助您針對工作階段設定建立 SDDL 的內容表。在您輸入 Register-PSSessionConfiguration 命令,然後重新啟動 WinRM 服務之後,就會顯示此內容表。
設定設定的權限時,請記住,使用者至少必須擁有 "Execute(Invoke)" 權限才能在工作階段中使用工作階段設定。
您無法在同一個命令中使用 SecurityDescriptorSDDL 參數和此參數。</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>StartupScript</maml:name>
<maml:description>
<maml:para>指定 Windows PowerShell 指令碼的完整路徑。指定的指令碼會在使用工作階段設定的新工作階段中執行。
您可以使用指令碼來進一步設定工作階段。如果指令碼產生錯誤 (即使是非終止錯誤),系統就不會建立工作階段,而且使用者的 New-PSSession 命令會失敗。</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>ThreadApartmentState</maml:name>
<maml:description>
<maml:para>決定工作階段中執行緒的 Apartment 狀態。有效的值包括 STA、MTA 和 Unknown。預設值為 Unknown。</maml:para>
</maml:description>
<command:parameterValueGroup>
<command:parameterValue required="false" variableLength="false">STA</command:parameterValue>
<command:parameterValue required="false" variableLength="false">MTA</command:parameterValue>
<command:parameterValue required="false" variableLength="false">Unknown</command:parameterValue>
</command:parameterValueGroup>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>ThreadOptions</maml:name>
<maml:description>
<maml:para>定義在工作階段中執行命令時,執行緒的建立和使用方式。有效的值包括 Default、ReuseThread、UseCurrentThread 和 UseNewThread。預設值為 UseCurrentThread。
</maml:para>
</maml:description>
<command:parameterValueGroup>
<command:parameterValue required="false" variableLength="false">Default</command:parameterValue>
<command:parameterValue required="false" variableLength="false">UseNewThread</command:parameterValue>
<command:parameterValue required="false" variableLength="false">ReuseThread</command:parameterValue>
<command:parameterValue required="false" variableLength="false">UseCurrentThread</command:parameterValue>
</command:parameterValueGroup>
</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="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>ApplicationBase</maml:name>
<maml:description>
<maml:para>指定 AssemblyName 參數值中指定之組件檔案 (*.dll) 的路徑。當 AssemblyName 參數的值沒有包含路徑時,請使用此參數。預設值為目前目錄。</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="true" variableLength="false" globbing="false" pipelineInput="false" position="2">
<maml:name>AssemblyName</maml:name>
<maml:description>
<maml:para>指定定義設定類型之組件檔案 (*.dll) 的名稱。您可以在這個參數或 ApplicationBase 參數的值中指定 .dll 的路徑。
指定 ConfigurationTypeName 參數時,此參數為必要項。</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="true" variableLength="false" globbing="false" pipelineInput="false" position="3">
<maml:name>ConfigurationTypeName</maml:name>
<maml:description>
<maml:para>指定用於此設定之 Microsoft .NET Framework 型別的完整名稱。您所指定的類型必須實作 System.Management.Automation.Remoting.PSSessionConfiguration 類別。
若要指定實作設定類型的組件檔案 (.dll),請使用 AssemblyName 和 AssemblyBase 參數。
建立類型可讓您控制更多工作階段設定的層面,例如公開或隱藏 Cmdlet 的特定參數,或是設定使用者無法覆寫的資料大小和物件大小限制。
如果您省略此參數,DefaultRemotePowerShellConfiguration 類別就會用於工作階段設定。</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>System.Management.Automation.Remoting.PSSessionConfiguration </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>抑制所有使用者提示,並重新啟動 WinRM 服務,而不進行提示。重新啟動服務可讓設定變更生效。
若要防止進行重新啟動並抑制重新啟動的提示,請使用 NoServiceRestart 參數。</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>MaximumReceivedDataSizePerCommandMB</maml:name>
<maml:description>
<maml:para>限制可在任何單一遠端命令中傳送至這部電腦的資料量。請輸入以 MB 為單位的資料大小。預設值為 50 MB。
如果資料大小限制定義於 ConfigurationTypeName 參數所指定的設定類型中,系統就會使用設定類型中的限制而忽略這個參數的值。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">double</command:parameterValue>
<dev:type>
<maml:name>double</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>50</dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>MaximumReceivedObjectSizeMB</maml:name>
<maml:description>
<maml:para>限制可在任何單一物件中傳送至這部電腦的資料量。請輸入以 MB 為單位的資料大小。預設值為 10 MB。
如果物件大小限制定義於 ConfigurationTypeName 參數所指定的設定類型中,系統就會使用設定類型中的限制而忽略這個參數的值。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">double</command:parameterValue>
<dev:type>
<maml:name>double</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>10</dev:defaultValue>
</command:parameter>
<command:parameter required="true" variableLength="false" globbing="false" pipelineInput="false" position="1">
<maml:name>Name</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:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>NoServiceRestart</maml:name>
<maml:description>
<maml:para>不重新啟動 WinRM 服務,並抑制重新啟動服務的提示。
根據預設,當您輸入 Register-PSSessionConfiguration 命令時,系統就會提示您重新啟動 WinRM 服務,讓新的工作階段設定生效。在重新啟動 WinRM 服務之前,新的工作階段設定不會生效。
若要重新啟動 WinRM 服務而不進行提示,請使用 Force 參數。若要手動重新啟動 WinRM 服務,請使用 Restart-Service 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>False</dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>ProcessorArchitecture</maml:name>
<maml:description>
<maml:para>指定設定的處理器架構。這個值會決定使用此設定時,系統將啟動裝載 Windows PowerShell 的 32 位元或 64 位元版本處理序。有效的值包括 x86、AMD64 和 IA64。
預設值是由裝載工作階段設定之電腦的處理器架構所決定。</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>SecurityDescriptorSDDL</maml:name>
<maml:description>
<maml:para>指定設定的安全性描述元定義語言 (SDDL) 字串。
這個字串會決定使用新工作階段設定所需的權限。若要在工作階段中使用工作階段設定,使用者至少必須擁有該設定的 "Execute(Invoke)" 權限。
如果安全性描述元很複雜,請考慮使用 ShowSecurityDescriptorUI 參數而非這個參數。您無法在同一個命令中使用這兩個參數。
如果您省略此參數,WinRM 服務的根 SDDL 就會用於這項設定。若要檢視或變更根 SDDL,請使用 WS-Management 提供者,例如 "get-item wsman:\localhost\service\rootSDDL"。如需 WS-Management 提供者的詳細資訊,請輸入 "get-help wsman"。</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>根 SDDL 的值</dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>ShowSecurityDescriptorUI</maml:name>
<maml:description>
<maml:para>顯示可協助您針對工作階段設定建立 SDDL 的內容表。在您輸入 Register-PSSessionConfiguration 命令,然後重新啟動 WinRM 服務之後,就會顯示此內容表。
設定設定的權限時,請記住,使用者至少必須擁有 "Execute(Invoke)" 權限才能在工作階段中使用工作階段設定。
您無法在同一個命令中使用 SecurityDescriptorSDDL 參數和此參數。</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>StartupScript</maml:name>
<maml:description>
<maml:para>指定 Windows PowerShell 指令碼的完整路徑。指定的指令碼會在使用工作階段設定的新工作階段中執行。
您可以使用指令碼來進一步設定工作階段。如果指令碼產生錯誤 (即使是非終止錯誤),系統就不會建立工作階段,而且使用者的 New-PSSession 命令會失敗。</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>ThreadApartmentState</maml:name>
<maml:description>
<maml:para>決定工作階段中執行緒的 Apartment 狀態。有效的值包括 STA、MTA 和 Unknown。預設值為 Unknown。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">ApartmentState</command:parameterValue>
<dev:type>
<maml:name>ApartmentState</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>Unknown</dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>ThreadOptions</maml:name>
<maml:description>
<maml:para>定義在工作階段中執行命令時,執行緒的建立和使用方式。有效的值包括 Default、ReuseThread、UseCurrentThread 和 UseNewThread。預設值為 UseCurrentThread。
</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">PSThreadOptions</command:parameterValue>
<dev:type>
<maml:name>PSThreadOptions</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>UseCurrentThread</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>無</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.WSMan.Management.WSManConfigContainerElement</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>
若要在 Windows Vista、Windows Server 2008 和更新版的 Windows 上執行這個 Cmdlet,您必須使用 [以系統管理員身分執行] 選項啟動 Windows PowerShell。
這個 Cmdlet 會產生代表 Web Services for Management (WS-Management) 外掛程式設定的 XML 並將此 XML 傳送至 WS-Management,以便在本機電腦上註冊外掛程式 ("new-item wsman:\localhost\plugin")。
</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>
register-pssessionConfiguration -name NewShell -applicationBase c:\MyShells\ -assemblyName MyShell.dll -configurationTypeName MyClass </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個命令會註冊 NewShell 工作階段設定。它會使用 ApplicationName 和 ApplicationBase 參數來指定 MyShell.dll 檔案的位置,而該檔案會指定工作階段設定中的 Cmdlet 和提供者。此外,它也會使用 ConfigurationTypeName 參數來指定進一步設定工作階段的新類別。
若要使用這項設定,使用者會輸入 "new-pssession -configurationname newshell"。</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>
register-pssessionConfiguration -name MaintenanceShell -startupScript c:\ps-test\Maintenance.ps1 </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個命令會在本機電腦上註冊 MaintenanceShell 設定。此命令會使用 StartupScript 參數來指定 Maintenance.ps1 指令碼。
當使用者使用 New-PSSession 命令並選取 MaintenanceShell 設定時,Maintenance.ps1 指令碼就會在新的工作階段中執行。該指令碼可以設定工作階段,包括匯入模組、新增 Windows PowerShell 嵌入式管理單元,以及設定工作階段的執行原則。如果該指令碼產生任何錯誤,包括非終止錯誤,New-PSSession 命令就會失敗。</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>
$sddl = "O:NSG:BAD:P(A;;GA;;;BA)S:P(AU;FA;GA;;;WD)(AU;FA;SA;GWGX;;WD)"
C:\PS> register-pssessionconfiguration -name AdminShell -securityDescriptorSDDL $sddl -maximumReceivedObjectSizeMB 20 -startupScript c:\scripts\AdminShell.ps1 </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個範例會註冊 AdminShell 工作階段設定。
第一個命令會將自訂 SDDL 儲存在 $sddl 變數中。
第二個命令會註冊新的殼層。此命令會使用 SecurityDescritorSDDL 參數來指定 $sddl 變數值中的 SDDL,並使用 MaximumReceivedObjectSizeMB 參數來提高物件大小限制。此外,它也會使用 StartupScript 參數來指定設定工作階段的指令碼。
除了使用 SecurityDescriptorSDDL 參數以外,您也可以使用 ShowSecurityDescriptorUI 參數,以便顯示可用來設定工作階段設定之權限的內容表。當您在內容表中按一下 [確定] 時,此工具就會產生工作階段設定的 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>
-------------------------- 範例 4 --------------------------
</maml:title>
<maml:introduction>
<maml:para>C:\PS></maml:para>
</maml:introduction>
<dev:code>
$s = register-pssessionConfiguration -name MaintenanceShell -startupScript c:\ps-test\Maintenance.ps1
C:\PS> $s
WSManConfig: Microsoft.WSMan.Management\WSMan::localhost\Plugin
Name Type Keys
---- ---- ----
MaintenanceShell Container {Name=MaintenanceShell}
C:\PS> $s.getType().fullname
TypeName: Microsoft.WSMan.Management.WSManConfigContainerElement
C:\PS> $s | format-list -property *
PSPath : Microsoft.WSMan.Management\WSMan::localhost\Plugin\MaintenanceShell
PSParentPath : Microsoft.WSMan.Management\WSMan::localhost\Plugin
PSChildName : MaintenanceShell
PSDrive : WSMan
PSProvider : Microsoft.WSMan.Management\WSMan
PSIsContainer : True
Keys : {Name=MaintenanceShell}
Name : MaintenanceShell
TypeNameOfElement : Container
C:\PS> dir wsman:\localhost\plugin
Name Type Keys
---- ---- ----
MaintenanceShell Container {Name=MaintenanceShell}
microsoft.powershell Container {Name=microsoft.powershell}
microsoft.powershell32 Container {Name=microsoft.powershell32}
</dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個範例會示範 Register-PSSessionConfiguration 命令將傳回 WSManConfigContainerElement,同時示範如何在 WSMan: 磁碟機中尋找容器元素。
第一個命令會使用 Register-PSSessionConfiguration Cmdlet 來註冊 MaintenanceShell 設定。它會將該 Cmdlet 所傳回的物件儲存在 $s 變數中。
第二個命令會顯示 $s 變數的內容。
第三個命令會使用 GetType 方法及其 FullName 屬性來顯示 Register-PSSessionConfiguration 所傳回之物件的類型名稱。
第四個命令會使用 Format-List Cmdlet,以清單顯示 Register-PSSessionConfiguration 所傳回之物件的所有屬性。PSPath 屬性會顯示該物件儲存在 WSMan: 磁碟機的目錄中。
第五個命令會使用 Get-ChildItem Cmdlet 來顯示 WSMan:\LocalHost\PlugIn 路徑中的項目。這些項目包括新的 MaintenanceShell 設定以及 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>
-------------------------- 範例 5 --------------------------
</maml:title>
<maml:introduction>
<maml:para>C:\PS></maml:para>
</maml:introduction>
<dev:code>
register-pssessionconfiguration -name WithProfile -startupScript add-profile.ps1
# Add-Profile.ps1
. c:\users\admin01\documents\windowspowershell\profile.ps1 </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個命令會在本機電腦上建立並註冊 WithProfile 工作階段設定。此命令會使用 StartupScript 參數來指示 Windows PowerShell 在使用該工作階段設定的任何工作階段設定中執行指定的指令碼。
系統也會顯示指定之指令碼 Add-Profile.ps1 的內容。此指令碼包含使用以句號表示起點的單一命令,可在工作階段的目前範圍中執行使用者的 CurrentUserAllHosts 設定檔。
如需設定檔的詳細資訊,請參閱 about_Profiles。如需以句號表示起點的詳細資訊,請參閱 about_Scopes。</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=144306</maml:uri>
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>about_Session_Configurations</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Disable-PSSessionConfiguration</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Enable-PSSessionConfiguration</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Get-PSSessionConfiguration</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Set-PSSessionConfiguration</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Unregister-PSSessionConfiguration</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>WS-Management Provider</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>
Remove-Job
</command:name>
<maml:description>
<maml:para>刪除 Windows PowerShell 背景工作。</maml:para>
</maml:description>
<maml:copyright>
<maml:para></maml:para>
</maml:copyright>
<command:verb>Remove</command:verb>
<command:noun>Job</command:noun>
<dev:version></dev:version>
</command:details>
<maml:description>
<maml:para>Remove-Job Cmdlet 會刪除利用 Start-Job 或任何 Cmdlet 之 AsJob 參數啟動的 Windows PowerShell 背景工作。
您可以使用這個 Cmdlet 刪除所有工作,或是依據工作的名稱、識別碼、執行個體識別碼、命令或狀態,或者將工作物件傳遞到 Remove-Job,以便刪除選取的工作。如果沒有使用參數或參數值,Remove-Job 就沒有作用。
刪除正在執行的工作之前,請先使用 Stop-Job Cmdlet 停止工作。如果嘗試刪除正在執行的工作,命令會失敗。您可以使用 Remove-Job 的 Force 參數來刪除正在執行的工作。
如果沒有刪除背景工作,工作便會保留在全域工作快取中,直到您關閉在其中建立工作的工作階段為止。</maml:para>
</maml:description>
<!-- Cmdlet syntax section-->
<command:syntax>
<command:syntaxItem>
<maml:name>Remove-Job</maml:name>
<command:parameter required="true" variableLength="true" globbing="false" pipelineInput="true (ByPropertyName)" position="1">
<maml:name>Id</maml:name>
<maml:description>
<maml:para>刪除具有指定之識別碼的背景工作。
識別碼是整數,可唯一識別目前工作階段內的工作。它比執行個體識別碼更容易記得和輸入,但是只有在目前的工作階段中才具有唯一性。您可以輸入一個或多個識別碼 (以逗號分隔)。若要尋找工作的識別碼,請輸入 "Get-Job" 且不要指定參數。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="true">Int32[]</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>刪除工作,即使狀態為 "Running" 也是如此。如果未指定 Force 參數,Remove-Job 就無法刪除正在執行的工作。</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:syntaxItem>
<maml:name>Remove-Job</maml:name>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="true (ByPropertyName)" position="named">
<maml:name>Command</maml:name>
<maml:description>
<maml:para>移除包括命令中指定之單字的工作。</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>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:syntaxItem>
<maml:name>Remove-Job</maml:name>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="true (ByPropertyName)" position="1">
<maml:name>InstanceId</maml:name>
<maml:description>
<maml:para>刪除具有指定之執行個體識別碼的工作。
執行個體識別碼是一種 GUID,它能夠唯一識別電腦上的工作。若要尋找工作的執行個體識別碼,請使用 Get-Job 或顯示工作物件。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="true">Guid[]</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>刪除工作,即使狀態為 "Running" 也是如此。如果未指定 Force 參數,Remove-Job 就無法刪除正在執行的工作。</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:syntaxItem>
<maml:name>Remove-Job</maml:name>
<command:parameter required="true" variableLength="true" globbing="false" pipelineInput="true (ByValue, ByPropertyName)" position="1">
<maml:name>Job</maml:name>
<maml:description>
<maml:para>指定要刪除的工作。請輸入包含工作的變數或可取得工作的命令。您也可以使用管線運算子將工作提交給 Remove-Job Cmdlet。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="true">Job[]</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>刪除工作,即使狀態為 "Running" 也是如此。如果未指定 Force 參數,Remove-Job 就無法刪除正在執行的工作。</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:syntaxItem>
<maml:name>Remove-Job</maml:name>
<command:parameter required="false" variableLength="true" globbing="true" pipelineInput="true (ByPropertyName)" position="1">
<maml:name>Name</maml:name>
<maml:description>
<maml:para>只刪除具有指定之好記名稱的工作。允許使用萬用字元。
即使在工作階段內,也無法保證好記名稱不會重複,因此在依名稱刪除工作時,請使用 WhatIf 和 Confirm 參數。</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>Force</maml:name>
<maml:description>
<maml:para>刪除工作,即使狀態為 "Running" 也是如此。如果未指定 Force 參數,Remove-Job 就無法刪除正在執行的工作。</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:syntaxItem>
<maml:name>Remove-Job</maml:name>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="true (ByPropertyName)" position="named">
<maml:name>State</maml:name>
<maml:description>
<maml:para>只刪除具有指定之狀態的工作。有效的值包括 NotStarted、Running、Completed、Stopped、Failed 和 Blocked。若要刪除狀態為 Running 的工作,請使用 Force 參數。</maml:para>
</maml:description>
<command:parameterValueGroup>
<command:parameterValue required="false" variableLength="false">NotStarted</command:parameterValue>
<command:parameterValue required="false" variableLength="false">Running</command:parameterValue>
<command:parameterValue required="false" variableLength="false">Completed</command:parameterValue>
<command:parameterValue required="false" variableLength="false">Failed</command:parameterValue>
<command:parameterValue required="false" variableLength="false">Stopped</command:parameterValue>
<command:parameterValue required="false" variableLength="false">Blocked</command:parameterValue>
</command:parameterValueGroup>
</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="false" variableLength="true" globbing="false" pipelineInput="true (ByPropertyName)" position="named">
<maml:name>Command</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>刪除工作,即使狀態為 "Running" 也是如此。如果未指定 Force 參數,Remove-Job 就無法刪除正在執行的工作。</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>Id</maml:name>
<maml:description>
<maml:para>刪除具有指定之識別碼的背景工作。
識別碼是整數,可唯一識別目前工作階段內的工作。它比執行個體識別碼更容易記得和輸入,但是只有在目前的工作階段中才具有唯一性。您可以輸入一個或多個識別碼 (以逗號分隔)。若要尋找工作的識別碼,請輸入 "Get-Job" 且不要指定參數。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="true">Int32[]</command:parameterValue>
<dev:type>
<maml:name>Int32[]</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue></dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="true (ByPropertyName)" position="1">
<maml:name>InstanceId</maml:name>
<maml:description>
<maml:para>刪除具有指定之執行個體識別碼的工作。
執行個體識別碼是一種 GUID,它能夠唯一識別電腦上的工作。若要尋找工作的執行個體識別碼,請使用 Get-Job 或顯示工作物件。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="true">Guid[]</command:parameterValue>
<dev:type>
<maml:name>Guid[]</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>Job</maml:name>
<maml:description>
<maml:para>指定要刪除的工作。請輸入包含工作的變數或可取得工作的命令。您也可以使用管線運算子將工作提交給 Remove-Job Cmdlet。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="true">Job[]</command:parameterValue>
<dev:type>
<maml:name>Job[]</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue></dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="true" pipelineInput="true (ByPropertyName)" position="1">
<maml:name>Name</maml:name>
<maml:description>
<maml:para>只刪除具有指定之好記名稱的工作。允許使用萬用字元。
即使在工作階段內,也無法保證好記名稱不會重複,因此在依名稱刪除工作時,請使用 WhatIf 和 Confirm 參數。</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="true (ByPropertyName)" position="named">
<maml:name>State</maml:name>
<maml:description>
<maml:para>只刪除具有指定之狀態的工作。有效的值包括 NotStarted、Running、Completed、Stopped、Failed 和 Blocked。若要刪除狀態為 Running 的工作,請使用 Force 參數。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">JobState</command:parameterValue>
<dev:type>
<maml:name>JobState</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.Management.Automation.Job</maml:name>
<maml:uri />
<maml:description />
</dev:type>
<maml:description>
<maml:para>
<!-- description -->
您可以經由管道將工作物件輸出至 Remove-Job。
</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>
</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>
$batch = get-job -name BatchJob
C:\PS> $batch | remove-job </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這些命令會從目前的工作階段刪除名為 BatchJob 的背景工作。第一個命令會使用 Get-Job Cmdlet 取得表示該項工作的物件,然後再將工作儲存到 $batch 變數。第二個命令會使用管線運算子 (|) 將工作傳送到 Remove-Job Cmdlet。
這個命令的作用等同於使用 Remove-Job 的 Job 參數,例如 "remove-job -job $batch"。</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-job | remove-job </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>
remove-job -state NotStarted </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>
-------------------------- 範例 4 --------------------------
</maml:title>
<maml:introduction>
<maml:para>C:\PS></maml:para>
</maml:introduction>
<dev:code>
remove-job -name *batch -force </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個命令會從目前的工作階段刪除好記名稱以 "batch" 結尾的所有工作,包括正在執行的工作。
它會使用 Remove-Job 的 Name 參數來指定工作名稱模式,並使用 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>
-------------------------- 範例 5 --------------------------
</maml:title>
<maml:introduction>
<maml:para>C:\PS></maml:para>
</maml:introduction>
<dev:code>
$j = invoke-command -computername Server01 -scriptblock {get-process} -asJob
C:\PS> $j | remove-job </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>在這個範例中,會示範如何使用 Remove-Job Cmdlet 移除利用 Invoke-Command Cmdlet 的 AsJob 參數在遠端電腦啟動的工作。
第一個命令會使用 Invoke-Command Cmdlet 在 Server01 電腦執行工作,並使用 AsJob 參數將命令當做背景工作來執行,然後將產生的工作物件儲存在 $j 變數中。
因為這個命令是使用 AsJob 參數,所以即使工作是在遠端電腦執行,仍會在本機電腦建立工作物件。因此,請使用本機命令來管理工作。
第二個命令會使用 Remove-Job Cmdlet 移除工作。它會使用管線運算子 (|) 將 $j 中的工作傳送給 Remove-Job。請注意,這是本機命令。移除使用 AsJob 參數啟動的遠端工作時,並不需要用到遠端命令。
</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>
$s = new-pssession -computername Server01
C:\PS> invoke-command -session $s -scriptblock {start-job -scriptblock {get-process} -name MyJob}
C:\PS> invoke-command -session $s -scriptblock {remove-job -name MyJob} </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>在這個範例中,會示範如何移除使用 Invoke-Command 執行 Start-Job 命令所啟動的工作。在本例中,工作物件是在遠端電腦建立,而且您是使用遠端命令來管理工作。
第一個命令會使用 New-PSSession Cmdlet,建立與 Server01 電腦之間的 PSSession (固定連線)。固定連線是在遠端執行 Start-Job 命令的必要條件。命令會將 PSSession 儲存在 $s 變數中。
第二個命令會使用 Invoke-Command Cmdlet,在 $s 中的 PSSession 裡執行 Start-Job 命令,而該工作會執行 Get-Process 命令。它會使用 Start-Job 的 Name 參數來指定工作的好記名稱。
第三個命令會使用 Invoke-Command Cmdlet,在 $s 中的 PSSession 裡執行 Remove-Job 命令。這個命令會使用 Remove-Job 的 Name 參數識別要刪除的工作。</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>
-------------------------- 範例 7 --------------------------
</maml:title>
<maml:introduction>
<maml:para>C:\PS></maml:para>
</maml:introduction>
<dev:code>
$j = start-job -script {get-process powershell}
C:\PS> $j | format-list -property *
C:\PS> remove-job -instanceID dce2ee73-f8c9-483e-bdd7-a549d8687eed
C:\PS> $j = start-job -script {get-process powershell}
C:\PS> $j | format-list -property *
HasMoreData : False
StatusMessage :
Location : localhost
Command : get-process powershell
JobStateInfo : Failed
Finished : System.Threading.ManualResetEvent
InstanceId : dce2ee73-f8c9-483e-bdd7-a549d8687eed
Id : 1
Name : Job1
ChildJobs : {Job2}
Output : {}
Error : {}
Progress : {}
Verbose : {}
Debug : {}
Warning : {}
StateChanged :
C:\PS> remove-job -instanceID dce2ee73-f8c9-483e-bdd7-a549d8687eed </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>在這個範例中,會示範如何依據執行工作的個體識別碼來移除工作。
第一個會命令會使用 Start-Job Cmdlet 來啟動背景工作。這個命令會將產生的工作物件儲存在 $j 變數中。
第二個命令會使用管線運算子 (|),將 $j 中的工作物件傳送到 Format-List 命令。Format-List 命令會使用值為 * (所有) 的 Property 參數,在清單中顯示工作物件的所有屬性。
工作物件顯示會列出 ID 和 InstanceID 屬性的值,以及物件的其他屬性。
第三個命令會使用 Remove-Job 命令,從目前的工作階段移除工作。若要產生此命令,您可以從物件顯示複製及貼上 InstanceID 值。
若要在 Windows PowerShell 主控台中複製值,請使用滑鼠選取值,然後再按 Enter 進行複製。若要貼上值,請按一下滑鼠右鍵。</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=113377</maml:uri>
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>about_Jobs</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>about_Job_Details</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>about_Remote_Jobs</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Start-Job</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Get-Job</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Receive-Job</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Wait-Job</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Stop-Job</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Invoke-Command</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>
Remove-Module
</command:name>
<maml:description>
<maml:para>從目前的工作階段移除模組。</maml:para>
</maml:description>
<maml:copyright>
<maml:para></maml:para>
</maml:copyright>
<command:verb>Remove</command:verb>
<command:noun>Module</command:noun>
<dev:version></dev:version>
</command:details>
<maml:description>
<maml:para>Remove-Module Cmdlet 會從目前的工作階段中移除模組的成員。
如果模組包含組件 (.dll),則此 Cmdlet 會移除組件所實作的所有成員,但不會卸載組件。</maml:para>
</maml:description>
<!-- Cmdlet syntax section-->
<command:syntax>
<command:syntaxItem>
<maml:name>Remove-Module</maml:name>
<command:parameter required="true" variableLength="true" globbing="false" pipelineInput="true (ByValue)" position="1">
<maml:name>ModuleInfo</maml:name>
<maml:description>
<maml:para>指定要移除的模組物件。請輸入包含模組物件 (PSModuleInfo) 的變數,或者輸入可取得模組物件的命令,例如 Get-Module 命令。您也可以經由管道將模組物件輸出至 Remove-Module。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="true">PSModuleInfo[]</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>移除模組,即使這些模組的存取模式是唯讀也一樣。</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:syntaxItem>
<maml:name>Remove-Module</maml:name>
<command:parameter required="true" variableLength="true" globbing="true" pipelineInput="true (ByValue)" position="1">
<maml:name>Name</maml:name>
<maml:description>
<maml:para>指定要移除的模組名稱。允許使用萬用字元。您也可以經由管道將名稱字串輸出至 Remove-Module。</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>Force</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>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="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>Force</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></dev:defaultValue>
</command:parameter>
<command:parameter required="true" variableLength="true" globbing="false" pipelineInput="true (ByValue)" position="1">
<maml:name>ModuleInfo</maml:name>
<maml:description>
<maml:para>指定要移除的模組物件。請輸入包含模組物件 (PSModuleInfo) 的變數,或者輸入可取得模組物件的命令,例如 Get-Module 命令。您也可以經由管道將模組物件輸出至 Remove-Module。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="true">PSModuleInfo[]</command:parameterValue>
<dev:type>
<maml:name>PSModuleInfo[]</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue></dev:defaultValue>
</command:parameter>
<command:parameter required="true" variableLength="true" globbing="true" pipelineInput="true (ByValue)" position="1">
<maml:name>Name</maml:name>
<maml:description>
<maml:para>指定要移除的模組名稱。允許使用萬用字元。您也可以經由管道將名稱字串輸出至 Remove-Module。</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:parameters>
<!-- Input - Output section-->
<command:inputTypes>
<command:inputType>
<dev:type>
<maml:name>System.String 或 System.Management.Automation.PSModuleInfo</maml:name>
<maml:uri />
<maml:description />
</dev:type>
<maml:description>
<maml:para>
<!-- description -->
您可以經由管道將模組名稱 (字串) 和模組物件輸出至 Remove-Module。
</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 -->
Remove-Module 不會產生任何輸出。
</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>
您也可以利用 Remove-Module 的別名 "rmo" 來表示此 Cmdlet。如需詳細資訊,請參閱 about_Aliases。
</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>
remove-module -name BitsTransfer </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個命令會從目前的工作階段中移除 BitsTransfer 模組。</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-module | remove-module </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>
"FileTransfer", "PSDiagnostics" | remove-module -verbose
VERBOSE: Performing operation "Remove-Module" on Target "filetransfer (Path: 'C:\Windows\system32\WindowsPowerShell\v1.0\Modules\f
iletransfer\filetransfer.psd1')".
VERBOSE: Performing operation "Remove-Module" on Target "Microsoft.BackgroundIntelligentTransfer.Management (Path: 'C:\Windows\
assembly\GAC_MSIL\Microsoft.BackgroundIntelligentTransfer.Management\1.0.0.0__31bf3856ad364e35\Microsoft.BackgroundIntelligentTransfe
r.Management.dll')".
VERBOSE: Performing operation "Remove-Module" on Target "psdiagnostics (Path: 'C:\Windows\system32\WindowsPowerShell\v1.0\Modules\
psdiagnostics\psdiagnostics.psd1')".
VERBOSE: Removing imported function 'Start-Trace'.
VERBOSE: Removing imported function 'Stop-Trace'.
VERBOSE: Removing imported function 'Enable-WSManTrace'.
VERBOSE: Removing imported function 'Disable-WSManTrace'.
VERBOSE: Removing imported function 'Enable-PSWSManCombinedTrace'.
VERBOSE: Removing imported function 'Disable-PSWSManCombinedTrace'.
VERBOSE: Removing imported function 'Set-LogProperties'.
VERBOSE: Removing imported function 'Get-LogProperties'.
VERBOSE: Removing imported function 'Enable-PSTrace'.
VERBOSE: Removing imported function 'Disable-PSTrace'.
VERBOSE: Performing operation "Remove-Module" on Target "PSDiagnostics (Path: 'C:\Windows\system32\WindowsPowerShell\v1.0\Modules\
psdiagnostics\PSDiagnostics.psm1')". </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個命令會從目前的工作階段移除 FileTransfer 和 PSDiagnostics 模組。
這個命令會使用管線運算子 (|) 將模組名稱傳送至 Remove-Module。它會使用 Verbose 一般參數來取得移除之成員的詳細資訊。
「詳細訊息」會顯示移除的項目。這些訊息各不相同,因為 BitsTransfer 模組包含一個實作其 Cmdlet 的組件,以及一個具有其專屬組件的巢狀模組。PSDiagnostics 模組包含可匯出函數的模組指令碼檔案 (.psm1)。</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>
$a = get-module BitsTransfer
C:\PS> remove-module -moduleInfo $a </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個命令會使用 ModuleInfo 參數來移除 BitsTransfer 模組。</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=141556</maml:uri>
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Get-Module</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Import-Module</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>about_modules</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>
Remove-PSSession
</command:name>
<maml:description>
<maml:para>關閉一個或多個 Windows PowerShell 工作階段 (PSSession)。</maml:para>
</maml:description>
<maml:copyright>
<maml:para></maml:para>
</maml:copyright>
<command:verb>Remove</command:verb>
<command:noun>PSSession</command:noun>
<dev:version></dev:version>
</command:details>
<maml:description>
<maml:para>Remove-PSSession Cmdlet 會關閉目前工作階段中的 Windows PowerShell 工作階段 (PSSession)。它會停止正在 PSSession 中執行的任何命令、結束 PSSession,並釋放 PSSession 所使用的資源。如果 PSSession 是連線到遠端電腦,那麼 Remove-PSSession 也會關閉本機與遠端電腦間的連線。
若要移除 PSSession,請輸入此工作階段的 Name、ComputerName、ID 或 InstanceID。
如果您已將 PSSession 儲存在變數中,則工作階段物件會保留在變數內,但是 PSSession 的狀態為 "Closed"。</maml:para>
</maml:description>
<!-- Cmdlet syntax section-->
<command:syntax>
<command:syntaxItem>
<maml:name>Remove-PSSession</maml:name>
<command:parameter required="false" variableLength="true" globbing="true" pipelineInput="true (ByPropertyName)" position="1">
<maml:name>ComputerName</maml:name>
<maml:description>
<maml:para>關閉連線至指定之電腦的 PSSession。允許使用萬用字元。
請輸入一部或多部遠端電腦的 NetBIOS 名稱、IP 位址或完整網域名稱。若要指定本機電腦,請輸入電腦名稱、"localhost" 或點 (.)。</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>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:syntaxItem>
<maml:name>Remove-PSSession</maml:name>
<command:parameter required="true" variableLength="true" globbing="false" pipelineInput="true (ByPropertyName)" position="1">
<maml:name>Id</maml:name>
<maml:description>
<maml:para>關閉具有指定之識別碼的 PSSession。請輸入一個或多個識別碼 (以逗號分隔),或使用範圍運算子 (..) 指定識別碼範圍。
識別碼是整數,可唯一識別目前工作階段中的 PSSession。它比 InstanceId 更容易記得和輸入,但是只有在目前的工作階段中才具有唯一性。若要尋找 PSSession 的識別碼,請輸入 Get-PSSession 且不要指定參數。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="true">Int32[]</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:syntaxItem>
<maml:name>Remove-PSSession</maml:name>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="true (ByPropertyName)" position="named">
<maml:name>InstanceId</maml:name>
<maml:description>
<maml:para>關閉具有指定之執行個體識別碼的 PSSession。
執行個體識別碼是一種 GUID,可唯一識別目前工作階段中的 PSSession。InstanceID 具有唯一性,即使單一電腦有多個正在執行的工作階段也一樣。
InstanceID 儲存在代表 PSSession 之物件的 InstanceID 屬性中。若要尋找目前工作階段中 PSSession 的 InstanceID,請輸入 "get-pssession | format-table Name, ComputerName, InstanceId"。
</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="true">Guid[]</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:syntaxItem>
<maml:name>Remove-PSSession</maml:name>
<command:parameter required="false" variableLength="true" globbing="true" pipelineInput="true (ByPropertyName)" position="named">
<maml:name>Name</maml:name>
<maml:description>
<maml:para>關閉具有指定之好記名稱的 PSSession。允許使用萬用字元。
因為 PSSession 的好記名稱可能會重複,所以使用 Name 參數時,請考慮一併在 Remove-PSSession 命令中使用 WhatIf 或 Confirm 參數。</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>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:syntaxItem>
<maml:name>Remove-PSSession</maml:name>
<command:parameter required="true" variableLength="true" globbing="false" pipelineInput="true (ByValue, ByPropertyName)" position="1">
<maml:name>Session</maml:name>
<maml:description>
<maml:para>指定要關閉之 PSSession 的工作階段物件。請輸入包含 PSSession 的變數,或者輸入建立或取得 PSSession 的命令,例如 New-PSSession 或 Get-PSSession 命令。您也可以經由管道將一個或多個工作階段物件輸出至 Remove-PSSession。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="true">PSSession[]</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="false" variableLength="true" globbing="true" pipelineInput="true (ByPropertyName)" position="1">
<maml:name>ComputerName</maml:name>
<maml:description>
<maml:para>關閉連線至指定之電腦的 PSSession。允許使用萬用字元。
請輸入一部或多部遠端電腦的 NetBIOS 名稱、IP 位址或完整網域名稱。若要指定本機電腦,請輸入電腦名稱、"localhost" 或點 (.)。</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="true" variableLength="true" globbing="false" pipelineInput="true (ByPropertyName)" position="1">
<maml:name>Id</maml:name>
<maml:description>
<maml:para>關閉具有指定之識別碼的 PSSession。請輸入一個或多個識別碼 (以逗號分隔),或使用範圍運算子 (..) 指定識別碼範圍。
識別碼是整數,可唯一識別目前工作階段中的 PSSession。它比 InstanceId 更容易記得和輸入,但是只有在目前的工作階段中才具有唯一性。若要尋找 PSSession 的識別碼,請輸入 Get-PSSession 且不要指定參數。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="true">Int32[]</command:parameterValue>
<dev:type>
<maml:name>Int32[]</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue></dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="true (ByPropertyName)" position="named">
<maml:name>InstanceId</maml:name>
<maml:description>
<maml:para>關閉具有指定之執行個體識別碼的 PSSession。
執行個體識別碼是一種 GUID,可唯一識別目前工作階段中的 PSSession。InstanceID 具有唯一性,即使單一電腦有多個正在執行的工作階段也一樣。
InstanceID 儲存在代表 PSSession 之物件的 InstanceID 屬性中。若要尋找目前工作階段中 PSSession 的 InstanceID,請輸入 "get-pssession | format-table Name, ComputerName, InstanceId"。
</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="true">Guid[]</command:parameterValue>
<dev:type>
<maml:name>Guid[]</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue></dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="true" pipelineInput="true (ByPropertyName)" position="named">
<maml:name>Name</maml:name>
<maml:description>
<maml:para>關閉具有指定之好記名稱的 PSSession。允許使用萬用字元。
因為 PSSession 的好記名稱可能會重複,所以使用 Name 參數時,請考慮一併在 Remove-PSSession 命令中使用 WhatIf 或 Confirm 參數。</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="true" variableLength="true" globbing="false" pipelineInput="true (ByValue, ByPropertyName)" position="1">
<maml:name>Session</maml:name>
<maml:description>
<maml:para>指定要關閉之 PSSession 的工作階段物件。請輸入包含 PSSession 的變數,或者輸入建立或取得 PSSession 的命令,例如 New-PSSession 或 Get-PSSession 命令。您也可以經由管道將一個或多個工作階段物件輸出至 Remove-PSSession。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="true">PSSession[]</command:parameterValue>
<dev:type>
<maml:name>PSSession[]</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.Management.Automation.Runspaces.PSSession
</maml:name>
<maml:uri />
<maml:description />
</dev:type>
<maml:description>
<maml:para>
<!-- description -->
您可以經由管道將工作階段物件輸出至 Remove-PSSession。
</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 -->
Remove-PSSession 不會傳回任何物件。
</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>
ID 參數為必要項。使用 "remove-pssession" 時一定要指定參數。若要刪除目前工作階段中的所有 PSSession,請輸入 "get-pssession | remove-pssession"。
PSSession 會使用固定連線與遠端電腦連線。請建立 PSSession 來執行共用資料的一系列命令。如需詳細資訊,請參閱 about_PSSessions。
PSSession 專屬於目前的工作階段。當您結束工作階段時,您在該工作階段中建立的 PSSession 都會強制關閉。
</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>
remove-pssession -id 1, 2 </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個命令會移除識別碼為 1 和 2 的 PSSession。</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-pssession | remove-pssession
C:\PS> remove-pssession -session (get-pssession)
C:\PS> $s = get-pssession
C:\PS> remove-pssession -session $s". </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這些命令會移除目前工作階段中的所有 PSSession。雖然這三個命令格式看起來並不同,但是卻有相同的效果。</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>
$r = get-pssession -computername Serv*
$r | remove-pssession </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>針對連線至電腦名稱開頭為 "Serv" 之電腦的所有 PSSession,這些命令會關閉這些 PSSession。</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-pssession | where {$_.port -eq 90} | remove-pssession </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個命令會關閉連線至連接埠 90 的 PSSession。您可以使用這個命令格式,依 ComputerName、Name、InstanceID 和 ID 以外的其他屬性來識別 PSSession。</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>
get-pssession | ft computername, instanceID -auto
ComputerName InstanceId
------------ ----------------
Server01 875d231b-2788-4f36-9f67-2e50d63bb82a
localhost c065ffa0-02c4-406e-84a3-dacb0d677868
Server02 4699cdbc-61d5-4e0d-b916-84f82ebede1f
Server03 4e5a3245-4c63-43e4-88d0-a7798bfc2414
TX-TEST-01 fc4e9dfa-f246-452d-9fa3-1adbdd64ae85
C:\PS> remove-pssession -InstanceID fc4e9dfa-f246-452d-9fa3-1adbdd64ae85 </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這些命令示範如何依據 PSSession 的執行個體識別碼 (RemoteRunspaceID) 來關閉 PSSession。
第一個命令會使用 Get-PSsession Cmdlet 取得目前工作階段中的 PSSession。它會使用管線運算子 (|),將 PSSession 傳送至 Format-Table Cmdlet (別名為 ft),並由後者以表格形式格式化其 ComputerName 和 InstanceID 屬性。AutoSize 參數 ("auto") 會壓縮各欄以供顯示。
從產生的顯示中,系統管理員可以識別要關閉的 PSSession,並將該 PSSession 的 InstanceID 複製到第二個命令中。
第二個命令會使用 Remove-PSSession Cmdlet 移除具有指定之執行個體識別碼的 PSSession。</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>
function EndPSS { get-pssession | remove-pssession } </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>此函數會刪除目前工作階段中的所有 PSSession。將此函數新增至 Windows PowerShell 設定檔之後,若要刪除所有的工作階段,只需輸入 "endpss" 即可。</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=135250</maml:uri>
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>about_PSSessions</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>about_Remote</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>New-PSSession</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Get-PSSession</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Enter-PSSession</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Exit-PSSession</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Invoke-Command</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>
Remove-PSSnapin
</command:name>
<maml:description>
<maml:para>移除目前工作階段中的 Windows PowerShell 嵌入式管理單元。</maml:para>
</maml:description>
<maml:copyright>
<maml:para></maml:para>
</maml:copyright>
<command:verb>Remove</command:verb>
<command:noun>PSSnapin</command:noun>
<dev:version></dev:version>
</command:details>
<maml:description>
<maml:para>Remove-PSSnapin Cmdlet 會從目前的工作階段移除 Windows PowerShell 嵌入式管理單元。您可以使用它來移除已新增到 Windows PowerShell 的嵌入式管理單元,不過,您無法用它來移除與 Windows PowerShell 一起安裝的嵌入式管理單元。
嵌入式管理單元在從目前的工作階段移除之後仍為載入狀態,但是,您已無法再於此工作階段中使用該嵌入式管理單元內的 Cmdlet 和提供者。</maml:para>
</maml:description>
<!-- Cmdlet syntax section-->
<command:syntax>
<command:syntaxItem>
<maml:name>Remove-PSSnapin</maml:name>
<command:parameter required="true" variableLength="true" globbing="true" pipelineInput="true (ByPropertyName)" position="1">
<maml:name>Name</maml:name>
<maml:description>
<maml:para>指定要從目前工作階段中移除之 Windows PowerShell 嵌入式管理單元的名稱。參數名稱 ("Name") 為選擇項,而且允許在其值中使用萬用字元 (*)。</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:syntaxItem>
</command:syntax>
<!-- Cmdlet parameter section -->
<command:parameters>
<command:parameter required="true" variableLength="true" globbing="true" pipelineInput="true (ByPropertyName)" position="1">
<maml:name>Name</maml:name>
<maml:description>
<maml:para>指定要從目前工作階段中移除之 Windows PowerShell 嵌入式管理單元的名稱。參數名稱 ("Name") 為選擇項,而且允許在其值中使用萬用字元 (*)。</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="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.Management.Automation.PSSnapInInfo</maml:name>
<maml:uri />
<maml:description />
</dev:type>
<maml:description>
<maml:para>
<!-- description -->
您可以經由管道將嵌入式管理單元物件輸出至 Remove-PSSnapin。
</maml:para>
</maml:description>
</command:inputType>
</command:inputTypes>
<command:returnValues>
<command:returnValue>
<dev:type>
<maml:name>無或 System.Management.Automation.PSSnapInInfo</maml:name>
<maml:uri />
<maml:description />
</dev:type>
<maml:description>
<maml:para>
<!-- description -->
根據預設,Remove-PsSnapin 不會產生任何輸出。不過,如果您使用 PassThru 參數,它就會產生代表嵌入式管理單元的 System.Management.Automation.PSSnapInInfo 物件。
</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>
您也可以利用內建的別名 "rsnp" 來參照 Remove-PSSnapin。如需詳細資訊,請參閱 about_Aliases。
Remove-PSSnapin 在從工作階段移除 Windows PowerShell 嵌入式管理單元之前,不會檢查嵌入式管理單元的版本。如果無法移除嵌入式管理單元,便會出現警告訊息,而且命令會失敗。
Remove-PSSnapin 只會影響目前的工作階段。如果您已將 Add-PSSnapin 命令新增至 Windows PowerShell 設定檔,則必須刪除此命令,未來建立工作階段時便不會包含該嵌入式管理單元。如需相關指示,請參閱 about_Profiles。
</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>
remove-pssnapin -name Microsoft.Exchange </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個命令會從目前的工作階段中移除 Microsoft.Exchange 嵌入式管理單元。當此命令完成時,此工作階段就無法再使用該嵌入式管理單元所支援的 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>
-------------------------- 範例 2 --------------------------
</maml:title>
<maml:introduction>
<maml:para>C:\PS></maml:para>
</maml:introduction>
<dev:code>
get-PSSnapIn smp* | remove-PSSnapIn </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個命令會從目前的工作階段中移除名稱開頭為 "smp" 的 Windows PowerShell 嵌入式管理單元。
此命令會使用 Get-PSSnapin Cmdlet 來取得代表這些嵌入式管理單元的物件。管線運算子 (|) 會將結果傳送到 Remove-PSSnapin Cmdlet,此 Cmdlet 會從工作階段中移除這些嵌入式管理單元。此工作階段中將無法再使用這個嵌入式管理單元所支援的提供者和 Cmdlet。
當您經由管道將物件輸出至 Remove-PSSnapin 時,這些物件的名稱就會與 Name 參數產生關聯,而這個參數會接受由管線傳入且包含 Name 屬性的物件。</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>
remove-pssnapin -name *event* </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個命令會移除名稱中包含 "event" 的所有 Windows PowerShell 嵌入式管理單元。這個命令會指定 "Name" 參數名稱,但是因為此參數名稱為選擇項,所以可以省略。</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=113378</maml:uri>
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Add-PSSnapin</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Get-PSSnapin</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>about_Profiles</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-PSDebug
</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>PSDebug</command:noun>
<dev:version></dev:version>
</command:details>
<maml:description>
<maml:para>Set-PSDebug Cmdlet 會開啟或關閉指令碼偵錯功能、設定追蹤層級並切換嚴格模式。
將 Trace 參數設定為 1 時,便會在執行指令碼時追蹤每一行內容。當此參數設定為 2 時,則會同時追蹤變數指派、函數呼叫和指令碼呼叫。如果指定 Step 參數,您會在每一行指令碼執行之前收到提示。</maml:para>
</maml:description>
<!-- Cmdlet syntax section-->
<command:syntax>
<command:syntaxItem>
<maml:name>Set-PSDebug</maml:name>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>Off</maml:name>
<maml:description>
<maml:para>關閉所有的指令碼偵錯功能。
注意:"set-strictmode -off" 命令會停用 "set-psdebug -strict" 命令所設定的驗證。如需詳細資訊,請參閱 Set-StrictMode。</maml:para>
</maml:description>
</command:parameter>
</command:syntaxItem>
<command:syntaxItem>
<maml:name>Set-PSDebug</maml:name>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>Step</maml:name>
<maml:description>
<maml:para>開啟指令碼逐步偵錯。執行每一行之前,系統會提示使用者停止、繼續或進入新的直譯器層級,以便檢查指令碼的狀態。
注意:指定 Step 參數時,會自動將 Trace 的層級設定為 1。</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>Strict</maml:name>
<maml:description>
<maml:para>指定如果尚未指定變數值就參考變數,直譯器就會擲回例外狀況。
注意:"set-strictmode -off" 命令會停用 "set-psdebug -strict" 命令所設定的驗證。如需詳細資訊,請參閱 Set-StrictMode。</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>Trace</maml:name>
<maml:description>
<maml:para>指定追蹤層級:
0 - 關閉指令碼追蹤
1 - 執行指令碼時追蹤其各行內容
2 - 追蹤指令碼行、變數指派、函數呼叫以及指令碼。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">int</command:parameterValue>
</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>Off</maml:name>
<maml:description>
<maml:para>關閉所有的指令碼偵錯功能。
注意:"set-strictmode -off" 命令會停用 "set-psdebug -strict" 命令所設定的驗證。如需詳細資訊,請參閱 Set-StrictMode。</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>Step</maml:name>
<maml:description>
<maml:para>開啟指令碼逐步偵錯。執行每一行之前,系統會提示使用者停止、繼續或進入新的直譯器層級,以便檢查指令碼的狀態。
注意:指定 Step 參數時,會自動將 Trace 的層級設定為 1。</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>Strict</maml:name>
<maml:description>
<maml:para>指定如果尚未指定變數值就參考變數,直譯器就會擲回例外狀況。
注意:"set-strictmode -off" 命令會停用 "set-psdebug -strict" 命令所設定的驗證。如需詳細資訊,請參閱 Set-StrictMode。</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>Trace</maml:name>
<maml:description>
<maml:para>指定追蹤層級:
0 - 關閉指令碼追蹤
1 - 執行指令碼時追蹤其各行內容
2 - 追蹤指令碼行、變數指派、函數呼叫以及指令碼。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">int</command:parameterValue>
<dev:type>
<maml:name>int</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>無</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>
</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-psdebug -trace 2; foreach ($i in 1..3) {$i}
DEBUG: 1+ Set-PsDebug -trace 2; foreach ($i in 1..3) {$i}
DEBUG: 1+ Set-PsDebug -trace 2; foreach ($i in 1..3) {$i}
1
DEBUG: 1+ Set-PsDebug -trace 2; foreach ($i in 1..3) {$i}
2
DEBUG: 1+ Set-PsDebug -trace 2; foreach ($i in 1..3) {$i}
3 </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個命令會將追蹤層級設定為 2,然後執行會顯示 1、2 和 3 等數字的指令碼。</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-psdebug -step; foreach ($i in 1..3) {$i}
DEBUG: 1+ Set-PsDebug -step; foreach ($i in 1..3) {$i}
Continue with this operation?
1+ Set-PsDebug -step; foreach ($i in 1..3) {$i}
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help
(default is "Y"):a
DEBUG: 1+ Set-PsDebug -step; foreach ($i in 1..3) {$i}
1
2
3 </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個命令會啟動逐步偵錯,然後
執行會顯示 1、2 和 3 等數字的指令碼。</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-psdebug -off; foreach ($i in 1..3) {$i}
1
2
3 </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個命令會關閉所有偵錯功能,然後執行會顯示 1、2 和 3 等數字的指令碼。</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-psdebug -strict; $NewVar
The variable $NewVar cannot be retrieved because it has not been set yet.
At line:1 char:28
+ Set-PsDebug -strict;$NewVar <<<< </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:examples>
<!-- Link section -->
<maml:relatedLinks>
<maml:navigationLink>
<maml:linkText>Online version:</maml:linkText>
<maml:uri>http://go.microsoft.com/fwlink/?LinkID=113398</maml:uri>
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>about_Debuggers</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Debug-Process</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Set-PSBreakpoint</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Set-StrictMode</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Write-Debug</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-PSSessionConfiguration
</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>PSSessionConfiguration</command:noun>
<dev:version></dev:version>
</command:details>
<maml:description>
<maml:para>Set-PSSessionConfiguration Cmdlet 會變更本機電腦上已註冊之工作階段設定的屬性。這是進階的 Cmdlet,適合系統管理員用來管理使用者的自訂工作階段設定。
請使用 Name 參數來識別您想要變更的設定。請使用其他參數來指定工作階段設定屬性的新值。若要從設定中刪除屬性值 (並使用預設值),請針對對應的參數輸入空字串 ("") 或 $null 值。
若要查看工作階段設定的屬性,請使用 Get-PSSessionConfiguration Cmdlet 或 WS-Management 提供者。如需 WS-Management 提供者的詳細資訊,請輸入 "get-help wsman"。</maml:para>
</maml:description>
<!-- Cmdlet syntax section-->
<command:syntax>
<command:syntaxItem>
<maml:name>Set-PSSessionConfiguration</maml:name>
<command:parameter required="true" variableLength="false" globbing="false" pipelineInput="false" position="2">
<maml:name>AssemblyName</maml:name>
<maml:description>
<maml:para>針對設定指定不同的組件檔案。請輸入定義設定類型之組件 (.dll) 檔案的路徑 (選擇項) 和檔案名稱。
如果您只有輸入名稱,也可以在 ApplicationBase 參數的值中輸入路徑。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">string</command:parameterValue>
</command:parameter>
<command:parameter required="true" variableLength="false" globbing="false" pipelineInput="false" position="3">
<maml:name>ConfigurationTypeName</maml:name>
<maml:description>
<maml:para>針對設定指定不同的設定類型。您所指定的類型必須實作 System.Management.Automation.Remoting.PSSessionConfiguration 類別。
如果您輸入 "$null" 或空字串,DefaultRemotePowerShellConfiguration 類別就會用於工作階段設定。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">string</command:parameterValue>
</command:parameter>
<command:parameter required="true" variableLength="false" globbing="false" pipelineInput="false" position="1">
<maml:name>Name</maml:name>
<maml:description>
<maml:para>指定您想要變更之工作階段設定的名稱。
您無法使用此參數來變更工作階段設定的名稱。</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>ApplicationBase</maml:name>
<maml:description>
<maml:para>變更 AssemblyName 參數值中指定之組件檔案 (*.dll) 的路徑。</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>Force</maml:name>
<maml:description>
<maml:para>抑制所有使用者提示,並重新啟動 WinRM 服務,而不進行提示。重新啟動服務可讓設定變更生效。
若要防止進行重新啟動並抑制重新啟動的提示,請使用 NoServiceRestart 參數。</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>MaximumReceivedDataSizePerCommandMB</maml:name>
<maml:description>
<maml:para>變更可在任何單一遠端命令中傳送至這部電腦的資料量限制。請輸入以 MB 為單位的資料大小。預設值為 50 MB。
如果資料大小限制定義於 ConfigurationTypeName 參數所指定的設定類型中,系統就會使用設定類型中的限制而忽略這個參數的值。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">double</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>MaximumReceivedObjectSizeMB</maml:name>
<maml:description>
<maml:para>變更可在任何單一物件中傳送至這部電腦的資料量限制。請輸入以 MB 為單位的資料大小。預設值為 10 MB。
如果物件大小限制定義於 ConfigurationTypeName 參數所指定的設定類型中,系統就會使用設定類型中的限制而忽略這個參數的值。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">double</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>NoServiceRestart</maml:name>
<maml:description>
<maml:para>不重新啟動 WinRM 服務,並抑制重新啟動服務的提示。
根據預設,當您輸入 Set-PSSessionConfiguration 命令時,系統就會提示您重新啟動 WinRM 服務,讓新的工作階段設定生效。在重新啟動 WinRM 服務之前,新的工作階段設定不會生效。
若要重新啟動 WinRM 服務而不進行提示,請使用 Force 參數。若要手動重新啟動 WinRM 服務,請使用 Restart-Service Cmdlet。</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>SecurityDescriptorSDDL</maml:name>
<maml:description>
<maml:para>針對設定指定不同的安全性描述元定義語言 (SDDL) 字串。
這個字串會決定使用新工作階段設定所需的權限。若要在工作階段中使用工作階段設定,使用者至少必須擁有該設定的 "Execute(Invoke)" 權限。
若要使用設定的預設安全性描述元,請輸入空字串 ("") 或 $null 值。預設值為 WSMan: 磁碟機中的根 SDDL。
如果安全性描述元很複雜,請考慮使用 ShowSecurityDescriptorUI 參數而非這個參數。您無法在同一個命令中使用這兩個參數。
</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>ShowSecurityDescriptorUI</maml:name>
<maml:description>
<maml:para>顯示可協助您針對工作階段設定建立新 SDDL 的內容表。在您輸入 Set-PSSessionConfiguration 命令,然後重新啟動 WinRM 服務之後,就會顯示此內容表。
設定設定的權限時,請記住,使用者至少必須擁有 "Execute(Invoke)" 權限才能在工作階段中使用工作階段設定。
您無法在同一個命令中使用 SecurityDescriptorSDDL 參數和此參數。</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>StartupScript</maml:name>
<maml:description>
<maml:para>新增或變更設定的啟動指令碼。請輸入 Windows PowerShell 指令碼的完整路徑。指定的指令碼會在使用工作階段設定的新工作階段中執行。
若要從工作階段設定中刪除啟動指令碼,請輸入空字串 ("") 或 $null 值。
您可以使用啟動指令碼來進一步設定使用者的工作階段。如果指令碼產生錯誤 (即使是非終止錯誤),系統就不會建立工作階段,而且使用者的 New-PSSession 命令會失敗。
</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>ThreadApartmentState</maml:name>
<maml:description>
<maml:para>變更工作階段中執行緒的 Apartment 狀態設定。有效的值包括 STA、MTA 和 Unknown。預設值為 Unknown。</maml:para>
</maml:description>
<command:parameterValueGroup>
<command:parameterValue required="false" variableLength="false">STA</command:parameterValue>
<command:parameterValue required="false" variableLength="false">MTA</command:parameterValue>
<command:parameterValue required="false" variableLength="false">Unknown</command:parameterValue>
</command:parameterValueGroup>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>ThreadOptions</maml:name>
<maml:description>
<maml:para>變更設定中的執行緒選項設定。這項設定會定義在工作階段中執行命令時,執行緒的建立和使用方式。有效的值包括 Default、ReuseThread、UseCurrentThread 和 UseNewThread。預設值為 UseCurrentThread。
</maml:para>
</maml:description>
<command:parameterValueGroup>
<command:parameterValue required="false" variableLength="false">Default</command:parameterValue>
<command:parameterValue required="false" variableLength="false">UseNewThread</command:parameterValue>
<command:parameterValue required="false" variableLength="false">ReuseThread</command:parameterValue>
<command:parameterValue required="false" variableLength="false">UseCurrentThread</command:parameterValue>
</command:parameterValueGroup>
</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="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>ApplicationBase</maml:name>
<maml:description>
<maml:para>變更 AssemblyName 參數值中指定之組件檔案 (*.dll) 的路徑。</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="true" variableLength="false" globbing="false" pipelineInput="false" position="2">
<maml:name>AssemblyName</maml:name>
<maml:description>
<maml:para>針對設定指定不同的組件檔案。請輸入定義設定類型之組件 (.dll) 檔案的路徑 (選擇項) 和檔案名稱。
如果您只有輸入名稱,也可以在 ApplicationBase 參數的值中輸入路徑。</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="true" variableLength="false" globbing="false" pipelineInput="false" position="3">
<maml:name>ConfigurationTypeName</maml:name>
<maml:description>
<maml:para>針對設定指定不同的設定類型。您所指定的類型必須實作 System.Management.Automation.Remoting.PSSessionConfiguration 類別。
如果您輸入 "$null" 或空字串,DefaultRemotePowerShellConfiguration 類別就會用於工作階段設定。</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>Force</maml:name>
<maml:description>
<maml:para>抑制所有使用者提示,並重新啟動 WinRM 服務,而不進行提示。重新啟動服務可讓設定變更生效。
若要防止進行重新啟動並抑制重新啟動的提示,請使用 NoServiceRestart 參數。</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>MaximumReceivedDataSizePerCommandMB</maml:name>
<maml:description>
<maml:para>變更可在任何單一遠端命令中傳送至這部電腦的資料量限制。請輸入以 MB 為單位的資料大小。預設值為 50 MB。
如果資料大小限制定義於 ConfigurationTypeName 參數所指定的設定類型中,系統就會使用設定類型中的限制而忽略這個參數的值。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">double</command:parameterValue>
<dev:type>
<maml:name>double</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>50</dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>MaximumReceivedObjectSizeMB</maml:name>
<maml:description>
<maml:para>變更可在任何單一物件中傳送至這部電腦的資料量限制。請輸入以 MB 為單位的資料大小。預設值為 10 MB。
如果物件大小限制定義於 ConfigurationTypeName 參數所指定的設定類型中,系統就會使用設定類型中的限制而忽略這個參數的值。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">double</command:parameterValue>
<dev:type>
<maml:name>double</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>10</dev:defaultValue>
</command:parameter>
<command:parameter required="true" variableLength="false" globbing="false" pipelineInput="false" position="1">
<maml:name>Name</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:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>NoServiceRestart</maml:name>
<maml:description>
<maml:para>不重新啟動 WinRM 服務,並抑制重新啟動服務的提示。
根據預設,當您輸入 Set-PSSessionConfiguration 命令時,系統就會提示您重新啟動 WinRM 服務,讓新的工作階段設定生效。在重新啟動 WinRM 服務之前,新的工作階段設定不會生效。
若要重新啟動 WinRM 服務而不進行提示,請使用 Force 參數。若要手動重新啟動 WinRM 服務,請使用 Restart-Service 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>SecurityDescriptorSDDL</maml:name>
<maml:description>
<maml:para>針對設定指定不同的安全性描述元定義語言 (SDDL) 字串。
這個字串會決定使用新工作階段設定所需的權限。若要在工作階段中使用工作階段設定,使用者至少必須擁有該設定的 "Execute(Invoke)" 權限。
若要使用設定的預設安全性描述元,請輸入空字串 ("") 或 $null 值。預設值為 WSMan: 磁碟機中的根 SDDL。
如果安全性描述元很複雜,請考慮使用 ShowSecurityDescriptorUI 參數而非這個參數。您無法在同一個命令中使用這兩個參數。
</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>ShowSecurityDescriptorUI</maml:name>
<maml:description>
<maml:para>顯示可協助您針對工作階段設定建立新 SDDL 的內容表。在您輸入 Set-PSSessionConfiguration 命令,然後重新啟動 WinRM 服務之後,就會顯示此內容表。
設定設定的權限時,請記住,使用者至少必須擁有 "Execute(Invoke)" 權限才能在工作階段中使用工作階段設定。
您無法在同一個命令中使用 SecurityDescriptorSDDL 參數和此參數。</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>StartupScript</maml:name>
<maml:description>
<maml:para>新增或變更設定的啟動指令碼。請輸入 Windows PowerShell 指令碼的完整路徑。指定的指令碼會在使用工作階段設定的新工作階段中執行。
若要從工作階段設定中刪除啟動指令碼,請輸入空字串 ("") 或 $null 值。
您可以使用啟動指令碼來進一步設定使用者的工作階段。如果指令碼產生錯誤 (即使是非終止錯誤),系統就不會建立工作階段,而且使用者的 New-PSSession 命令會失敗。
</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>ThreadApartmentState</maml:name>
<maml:description>
<maml:para>變更工作階段中執行緒的 Apartment 狀態設定。有效的值包括 STA、MTA 和 Unknown。預設值為 Unknown。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">ApartmentState</command:parameterValue>
<dev:type>
<maml:name>ApartmentState</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>ApartmentState.Unknown</dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>ThreadOptions</maml:name>
<maml:description>
<maml:para>變更設定中的執行緒選項設定。這項設定會定義在工作階段中執行命令時,執行緒的建立和使用方式。有效的值包括 Default、ReuseThread、UseCurrentThread 和 UseNewThread。預設值為 UseCurrentThread。
</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">PSThreadOptions</command:parameterValue>
<dev:type>
<maml:name>PSThreadOptions</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>PSThreadOptions.UserCurrentThread</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>無</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.WSMan.Management.WSManConfigLeafElement</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>
若要在 Windows Vista、Windows Server 2008 和更新版的 Windows 上執行這個 Cmdlet,您必須使用 [以系統管理員身分執行] 選項開啟 Windows PowerShell。
Set-PSSessionConfiguration Cmdlet 不會變更設定名稱,而且 WS-Management 提供者不支援 Rename-Item Cmdlet。若要變更設定的名稱,請使用 Unregister-PSSessionConfiguration Cmdlet 來刪除設定,然後使用 Register-PSSessionConfiguration Cmdlet 來建立並註冊新的工作階段設定。
您可以使用 Set-PSSessionConfiguration Cmdlet 來變更預設的 Microsoft.PowerShell 和 Microsoft.PowerShell32 工作階段設定。這些設定沒有受到保護。若要回復成預設工作階段設定的原始版本,請使用 Unregister-PSSessionConfiguration Cmdlet 來刪除預設的工作階段設定,然後使用 Enable-PSRemoting Cmdlet 來進行還原。
</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-pssessionconfiguration -name MaintenanceShell -threadApartmentState STA </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個命令會將 MaintenanceShell 設定中的執行緒 Apartment 狀態變更為 STA。此變更會在您重新啟動 WinRM 服務時生效。</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>
register-pssessionconfiguration -name AdminShell -assemblyName c:\shells\AdminShell.dll -configurationType AdminClass
C:\PS> set-pssessionconfiguration -name AdminShell -startupScript AdminConfig.ps1
C:\PS> set-pssessionconfiguration -name AdminShell -startupScript $null </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個範例會示範如何建立工作階段設定,然後進行變更。
第一個命令會使用 Register-PSSessionConfiguration Cmdlet 來建立 AdminShell 設定。
第二個命令會使用 Set-PSSessionConfiguration Cmdlet,將 AdminConfig.ps1 指令碼新增至設定。此變更會在您重新啟動 WinRM 時生效。
第三個命令會從設定中移除 AdminConfig.ps1 指令碼。它會使用 Set-PSSessionConfiguration Cmdlet 搭配值為 $null 的 StartupScript 參數。</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-PSSessionConfiguration -name foo -MaximumReceivedObjectSizeMB 20
WSManConfig: Microsoft.WSMan.Management\WSMan::localhost\Plugin\foo\InitializationParameters
ParamName ParamValue
--------- ----------
psmaximumreceivedobjectsizemb 20
"Restart WinRM service"
WinRM service need to be restarted to make the changes effective. Do you want to run the command "restart-service winrm"?
[Y] Yes [N] No [S] Suspend [?] Help (default is "Y"): y </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個範例會示範 Set-PSSessionConfiguration Cmdlet 的範例輸出。
這個範例中的 Set-PSSessionConfiguration 命令會將 MaximumReceivedObjectSizeMB 屬性的值提高為 20。
Set-PSSessionConfiguration 命令會傳回顯示參數名稱和新值的 Microsoft.WSMan.Management.WSManConfigLeafElement 物件。
它也會提示您重新啟動 WinRM 服務。在重新啟動 WinRM 服務之前,Set-PSSessionConfiguration 變更不會生效。</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-pssessionconfiguration -name MaintenanceShell -startupScript c:\ps-test\Maintenance.ps1
WSManConfig: Microsoft.WSMan.Management\WSMan::localhost\Plugin\MaintenanceShell\InitializationParameters
ParamName ParamValue
--------- ----------
startupscript c:\ps-test\Mainte...
"Restart WinRM service"
WinRM service need to be restarted to make the changes effective. Do you want to run the command "restart-service winrm"?
[Y] Yes [N] No [S] Suspend [?] Help (default is "Y"): y
C:\PS> get-pssessionConfiguration maintenanceshell | format-list -property *
xmlns : http://schemas.microsoft.com/wbem/wsman/1/config/PluginConfiguration
Name : MaintenanceShell
Filename : %windir%\system32\pwrshplugin.dll
SDKVersion : 1
XmlRenderingType : text
lang : en-US
PSVersion : 2.0
startupscript : c:\ps-test\Maintenance.ps1
ResourceUri : http://schemas.microsoft.com/powershell/MaintenanceShell
SupportsOptions : true
ExactMatch : true
Capability : {Shell}
Permission :
C:\PS> dir wsman:\localhost\plugin\MaintenanceShell\InitializationParameters
ParamName ParamValue
--------- ----------
PSVersion 2.0
startupscript c:\ps-test\Maintenance.ps1 </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個命令會示範檢視 Set-PSSessionConfiguration 命令結果的不同方式。
第一個命令會使用 Set-PSSessionConfiguration Cmdlet,將 MaintenanceShell 設定中的啟動指令碼變更為 Maintenance.ps1。這個命令的輸出會顯示變更並提示您重新啟動 WinRM 服務。其回應為 "y" (是)。
第二個命令會使用 Get-PSSessionConfiguration Cmdlet 來取得 MaintenanceShell 工作階段設定。此命令會使用管線運算子 (|),將命令的結果傳送至 Format-List Cmdlet,並由後者將工作設定物件的所有屬性顯示在清單中。
第三個命令會使用 WS-Management 提供者來檢視 MaintenanceShell 設定的初始化參數。此命令會使用 Get-ChildItem Cmdlet (別名為 dir) 來取得 MaintenanceShell 外掛程式之 InitializationParameters 節點中的子項目。
如需 WS-Management 提供者的詳細資訊,請輸入 "get-help wsman"。
</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=144307</maml:uri>
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>about_Session_Configurations</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Disable-PSSessionConfiguration</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Enable-PSSessionConfiguration</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Get-PSSessionConfiguration</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Register-PSSessionConfiguration</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Unregister-PSSessionConfiguration</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>WS-Management Provider</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-StrictMode
</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>StrictMode</command:noun>
<dev:version></dev:version>
</command:details>
<maml:description>
<maml:para>Set-StrictMode Cmdlet 會為目前範圍 (與所有子範圍) 設定嚴格模式,並開啟及關閉它。開啟嚴格模式後,當運算式、指令碼或指令碼區塊違反基本的最佳程式碼規則時,Windows PowerShell 將會產生終止錯誤。
請使用 Version 參數來判斷已強制施行哪些程式碼規則。
與 Set-PSDebug Cmdlet 不同,Set-StrictMode 只會影響目前的範圍及其子範圍,因此您可以在指令碼或函數中使用它,而不會影響全域範圍。
當 Set-StrictMode 關閉時,則會假設尚未初始化之變數 (第 1 版) 的值為 0 (零) 或 $null (視類型而定)。若參考不存在的屬性則傳回 $null,而且無效函數語法的結果則會隨著錯誤而不同。不允許使用未具名的變數。</maml:para>
</maml:description>
<!-- Cmdlet syntax section-->
<command:syntax>
<command:syntaxItem>
<maml:name>Set-StrictMode</maml:name>
<command:parameter required="true" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>Off</maml:name>
<maml:description>
<maml:para>關閉嚴格模式。此參數也會關閉 "Set-PSDebug -Strict"。</maml:para>
</maml:description>
</command:parameter>
</command:syntaxItem>
<command:syntaxItem>
<maml:name>Set-StrictMode</maml:name>
<command:parameter required="true" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>Version</maml:name>
<maml:description>
<maml:para>指定在嚴格模式中導致錯誤發生的狀況。此參數為必要項。
有效的值包括 "1.0"、"2.0" 和 "Latest"。下列清單會顯示每個值的作用。
1.0
-- 禁止參考尚未初始化的變數 (字串中尚未初始化的變數除外)。
2.0
-- 禁止參考尚未初始化的變數 (包括字串中尚未初始化的變數)。
-- 禁止參考不存在的物件屬性。
-- 禁止使用用來呼叫方法之語法的函數呼叫。
-- 禁止沒有名稱的變數 (${})。
Latest:
-- 選取可用的最新 (最嚴格) 版本。請使用這個值確保指令碼會使用最嚴格的可用版本,即使新版本已新增至 Windows PowerShell 也不例外。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">Version</command:parameterValue>
</command:parameter>
</command:syntaxItem>
</command:syntax>
<!-- Cmdlet parameter section -->
<command:parameters>
<command:parameter required="true" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>Off</maml:name>
<maml:description>
<maml:para>關閉嚴格模式。此參數也會關閉 "Set-PSDebug -Strict"。</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="false" globbing="false" pipelineInput="false" position="named">
<maml:name>Version</maml:name>
<maml:description>
<maml:para>指定在嚴格模式中導致錯誤發生的狀況。此參數為必要項。
有效的值包括 "1.0"、"2.0" 和 "Latest"。下列清單會顯示每個值的作用。
1.0
-- 禁止參考尚未初始化的變數 (字串中尚未初始化的變數除外)。
2.0
-- 禁止參考尚未初始化的變數 (包括字串中尚未初始化的變數)。
-- 禁止參考不存在的物件屬性。
-- 禁止使用用來呼叫方法之語法的函數呼叫。
-- 禁止沒有名稱的變數 (${})。
Latest:
-- 選取可用的最新 (最嚴格) 版本。請使用這個值確保指令碼會使用最嚴格的可用版本,即使新版本已新增至 Windows PowerShell 也不例外。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">Version</command:parameterValue>
<dev:type>
<maml:name>Version</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>無</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-StrictMode 類似於 Set-PSDebug 的 Strict 參數。"Set-Strictmode -version 1" 的作用等同於 "Set-PSDebug -strict",唯一的不同是 Set-PSDebug 對所有的範圍都有效,而 Set-StrictMode 只對其設定範圍及其子範圍有效。如需 Windows PowerShell 中範圍的詳細資訊,請參閱 about_Scopes。
</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-strictmode -version 1.0
C:\PS> $a -gt 5
False
The variable $a cannot be retrieved because it has not been set yet.
At line:1 char:3
+ $a <<<< -gt 5
+ CategoryInfo : InvalidOperation: (a:Token) [], RuntimeException
+ FullyQualifiedErrorId : VariableIsUndefined </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個命令會開啟嚴格模式,並將它設定為 1.0 版。因此,嘗試參考未初始化的變數將會失敗。
範例輸出會顯示 1.0 版嚴格模式的效果。</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-strictmode -version 2.0
# Strict mode is off by default.
C:\PS> function add ($a, $b) {$a + $b}
C:\PS> add 3 4
7
C:\PS> add(3,4)
3
4
C:\PS> set-strictmode -version 2.0
C:\PS> add(3,4)
The function or command was called like a method. Parameters should be separated by spaces, as described in 'Get-Help about_Parameter.'
At line:1 char:4
+ add <<<< (3,4)
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : StrictModeFunctionCallWithParens
C:\PS> set-strictmode -off
C:\PS> $string = "This is a string".
C:\PS> $string.Month
C:\PS>
C:\PS> set-strictmode -version 2.0
C:\PS> $string = "This is a string".
C:\PS> $string.Month
Property 'month' cannot be found on this object; make sure it exists.
At line:1 char:9
+ $string. <<<< month
+ CategoryInfo : InvalidOperation: (.:OperatorToken) [], RuntimeException
+ FullyQualifiedErrorId : PropertyNotFoundStrict </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個命令會開啟嚴格模式,並將它設定為 2.0 版。因此,如果您將方法語法 (括號和逗號) 用於函數呼叫,或是參考未初始化的變數或不存在的屬性,Windows PowerShell 便會擲回錯誤。
範例輸出會顯示 2.0 版嚴格模式的效果。
若未指定 2.0 版嚴格模式,值 "(3,4)" 會解譯為未加入任何項目的單一陣列物件。若指定 2.0 版嚴格模式,則會正確解譯為提交兩個值的錯誤語法。
若未指定 2.0 版,參考不存在的字串屬性 Month 時只會傳回 null。若指定 2.0 版,便會正確解譯為參考錯誤。</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=113450</maml:uri>
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>about_Debuggers</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>about_Scopes</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Set-PSDebug</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>
Start-Job
</command:name>
<maml:description>
<maml:para>啟動 Windows PowerShell 背景工作。</maml:para>
</maml:description>
<maml:copyright>
<maml:para></maml:para>
</maml:copyright>
<command:verb>Start</command:verb>
<command:noun>Job</command:noun>
<dev:version></dev:version>
</command:details>
<maml:description>
<maml:para>Start-Job Cmdlet 會在本機電腦啟動 Windows PowerShell 背景工作。
Windows PowerShell 背景工作會「在背景中」執行命令,且與目前工作階段沒有任何互動。當您啟動背景工作時,即使工作需要很長的時間才能完成,還是會立即傳回工作物件。您可以在工作執行期間,繼續在工作階段中執行作業而不需中斷。
工作物件包含有用的工作資訊,但不包含工作結果。當工作完成時,請使用 Receive-Job Cmdlet 取得工作的結果。如需背景工作的詳細資訊,請參閱 about_Jobs。
若要在遠端電腦執行背景工作,請使用許多 Cmdlet 都有提供的 AsJob 參數,或使用 Invoke-Command Cmdlet 在遠端電腦執行 Start-Job 命令。如需詳細資訊,請參閱 about_Remote_Jobs。</maml:para>
</maml:description>
<!-- Cmdlet syntax section-->
<command:syntax>
<command:syntaxItem>
<maml:name>Start-Job</maml:name>
<command:parameter required="true" variableLength="false" globbing="false" pipelineInput="false" position="1">
<maml:name>ScriptBlock</maml:name>
<maml:description>
<maml:para>指定要在背景工作中執行的命令。請以大括號 ( { } ) 括住命令以建立指令碼區塊。此參數為必要項。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">scriptblock</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="2">
<maml:name>InitializationScript</maml:name>
<maml:description>
<maml:para>指定在工作啟動之前執行的命令。請以大括號 ( { } ) 括住命令以建立指令碼區塊。
請使用此參數來準備工作執行所在的工作階段。例如,您可以使用此參數,將函數、嵌入式管理單元和模組新增至工作階段。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">scriptblock</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="false" position="named">
<maml:name>ArgumentList</maml:name>
<maml:description>
<maml:para>為 FilePath 參數所指定的指令碼指定引數 (參數值)。
由於接在 ArgumentList 參數名稱後面的所有值都會解譯成 ArgumentList 的值,因此 ArgumentList 參數必須是命令中的最後一個參數。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="true">Object[]</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>Authentication</maml:name>
<maml:description>
<maml:para>指定用來驗證使用者認證的機制。有效值為 Default、Basic、Credssp、Digest、Kerberos、Negotiate 和 NegotiateWithImplicitCredential。預設值為 Default。
CredSSP 驗證僅適用於 Windows Vista、Windows Server 2008 和更新版的 Windows。
如需此參數之值的詳細資訊,請參閱 MSDN 中的 System.Management.Automation.Runspaces.AuthenticationMechanism 列舉說明。
警告:認證安全性服務提供者 (CredSSP) 驗證 (其中使用者的認證會傳送到遠端電腦) 是專為需要對一個以上的資源進行驗證的命令所設計,例如存取遠端網路共用。此機制會提高遠端操作的安全性風險。如果遠端電腦已經遭受危害,則傳遞給遠端電腦的認證可能會被用來控制網路工作階段。</maml:para>
</maml:description>
<command:parameterValueGroup>
<command:parameterValue required="false" variableLength="false">Default</command:parameterValue>
<command:parameterValue required="false" variableLength="false">Basic</command:parameterValue>
<command:parameterValue required="false" variableLength="false">Negotiate</command:parameterValue>
<command:parameterValue required="false" variableLength="false">NegotiateWithImplicitCredential</command:parameterValue>
<command:parameterValue required="false" variableLength="false">Credssp</command:parameterValue>
<command:parameterValue required="false" variableLength="false">Digest</command:parameterValue>
<command:parameterValue required="false" variableLength="false">Kerberos</command:parameterValue>
</command:parameterValueGroup>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>Credential</maml:name>
<maml:description>
<maml:para>指定具有執行此動作之權限的使用者帳戶。預設為目前使用者。
請輸入使用者名稱,例如 "User01" 或 "Domain01\User01",或是輸入 PSCredential 物件,例如由 Get-Credential Cmdlet 所產生的物件。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">PSCredential</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="true (ByValue)" position="named">
<maml:name>InputObject</maml:name>
<maml:description>
<maml:para>指定命令的輸入。請輸入包含物件的變數,或輸入可產生物件的命令或運算式。
請在 ScriptBlock 參數的值中使用 $input 自動變數,以表示輸入物件。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">psobject</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="true (ByPropertyName)" position="named">
<maml:name>Name</maml:name>
<maml:description>
<maml:para>指定新工作的好記名稱。您可以使用這個名稱讓其他工作 Cmdlet (例如 Stop-Job) 識別此工作。
預設的好記名稱是 Job#,其中 "#" 是隨著每一項工作遞增的序數。</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>RunAs32</maml:name>
<maml:description>
<maml:para>在 32 位元處理序中執行此工作。
請使用此參數來強制工作在 64 位元作業系統上的 32 位元處理序中執行。</maml:para>
</maml:description>
</command:parameter>
</command:syntaxItem>
<command:syntaxItem>
<maml:name>Start-Job</maml:name>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="1">
<maml:name>FilePath</maml:name>
<maml:description>
<maml:para>將指定的本機指令碼當做背景工作來執行。請輸入指令碼的路徑和檔名,或經由管道將指令碼路徑輸出至 Start-Job。此指令碼必須存在於本機電腦或本機電腦可存取的目錄中。
使用此參數時,Windows PowerShell 會將指定之指令碼檔案的內容轉換成指令碼區塊,並將該指令碼區塊當做背景工作來執行。</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="2">
<maml:name>InitializationScript</maml:name>
<maml:description>
<maml:para>指定在工作啟動之前執行的命令。請以大括號 ( { } ) 括住命令以建立指令碼區塊。
請使用此參數來準備工作執行所在的工作階段。例如,您可以使用此參數,將函數、嵌入式管理單元和模組新增至工作階段。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">scriptblock</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="false" position="named">
<maml:name>ArgumentList</maml:name>
<maml:description>
<maml:para>為 FilePath 參數所指定的指令碼指定引數 (參數值)。
由於接在 ArgumentList 參數名稱後面的所有值都會解譯成 ArgumentList 的值,因此 ArgumentList 參數必須是命令中的最後一個參數。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="true">Object[]</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>Authentication</maml:name>
<maml:description>
<maml:para>指定用來驗證使用者認證的機制。有效值為 Default、Basic、Credssp、Digest、Kerberos、Negotiate 和 NegotiateWithImplicitCredential。預設值為 Default。
CredSSP 驗證僅適用於 Windows Vista、Windows Server 2008 和更新版的 Windows。
如需此參數之值的詳細資訊,請參閱 MSDN 中的 System.Management.Automation.Runspaces.AuthenticationMechanism 列舉說明。
警告:認證安全性服務提供者 (CredSSP) 驗證 (其中使用者的認證會傳送到遠端電腦) 是專為需要對一個以上的資源進行驗證的命令所設計,例如存取遠端網路共用。此機制會提高遠端操作的安全性風險。如果遠端電腦已經遭受危害,則傳遞給遠端電腦的認證可能會被用來控制網路工作階段。</maml:para>
</maml:description>
<command:parameterValueGroup>
<command:parameterValue required="false" variableLength="false">Default</command:parameterValue>
<command:parameterValue required="false" variableLength="false">Basic</command:parameterValue>
<command:parameterValue required="false" variableLength="false">Negotiate</command:parameterValue>
<command:parameterValue required="false" variableLength="false">NegotiateWithImplicitCredential</command:parameterValue>
<command:parameterValue required="false" variableLength="false">Credssp</command:parameterValue>
<command:parameterValue required="false" variableLength="false">Digest</command:parameterValue>
<command:parameterValue required="false" variableLength="false">Kerberos</command:parameterValue>
</command:parameterValueGroup>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>Credential</maml:name>
<maml:description>
<maml:para>指定具有執行此動作之權限的使用者帳戶。預設為目前使用者。
請輸入使用者名稱,例如 "User01" 或 "Domain01\User01",或是輸入 PSCredential 物件,例如由 Get-Credential Cmdlet 所產生的物件。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">PSCredential</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="true (ByValue)" position="named">
<maml:name>InputObject</maml:name>
<maml:description>
<maml:para>指定命令的輸入。請輸入包含物件的變數,或輸入可產生物件的命令或運算式。
請在 ScriptBlock 參數的值中使用 $input 自動變數,以表示輸入物件。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">psobject</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="true (ByPropertyName)" position="named">
<maml:name>Name</maml:name>
<maml:description>
<maml:para>指定新工作的好記名稱。您可以使用這個名稱讓其他工作 Cmdlet (例如 Stop-Job) 識別此工作。
預設的好記名稱是 Job#,其中 "#" 是隨著每一項工作遞增的序數。</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>RunAs32</maml:name>
<maml:description>
<maml:para>在 32 位元處理序中執行此工作。
請使用此參數來強制工作在 64 位元作業系統上的 32 位元處理序中執行。</maml:para>
</maml:description>
</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>ArgumentList</maml:name>
<maml:description>
<maml:para>為 FilePath 參數所指定的指令碼指定引數 (參數值)。
由於接在 ArgumentList 參數名稱後面的所有值都會解譯成 ArgumentList 的值,因此 ArgumentList 參數必須是命令中的最後一個參數。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="true">Object[]</command:parameterValue>
<dev:type>
<maml:name>Object[]</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>Authentication</maml:name>
<maml:description>
<maml:para>指定用來驗證使用者認證的機制。有效值為 Default、Basic、Credssp、Digest、Kerberos、Negotiate 和 NegotiateWithImplicitCredential。預設值為 Default。
CredSSP 驗證僅適用於 Windows Vista、Windows Server 2008 和更新版的 Windows。
如需此參數之值的詳細資訊,請參閱 MSDN 中的 System.Management.Automation.Runspaces.AuthenticationMechanism 列舉說明。
警告:認證安全性服務提供者 (CredSSP) 驗證 (其中使用者的認證會傳送到遠端電腦) 是專為需要對一個以上的資源進行驗證的命令所設計,例如存取遠端網路共用。此機制會提高遠端操作的安全性風險。如果遠端電腦已經遭受危害,則傳遞給遠端電腦的認證可能會被用來控制網路工作階段。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">AuthenticationMechanism</command:parameterValue>
<dev:type>
<maml:name>AuthenticationMechanism</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>Credential</maml:name>
<maml:description>
<maml:para>指定具有執行此動作之權限的使用者帳戶。預設為目前使用者。
請輸入使用者名稱,例如 "User01" 或 "Domain01\User01",或是輸入 PSCredential 物件,例如由 Get-Credential Cmdlet 所產生的物件。</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:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="1">
<maml:name>FilePath</maml:name>
<maml:description>
<maml:para>將指定的本機指令碼當做背景工作來執行。請輸入指令碼的路徑和檔名,或經由管道將指令碼路徑輸出至 Start-Job。此指令碼必須存在於本機電腦或本機電腦可存取的目錄中。
使用此參數時,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="false" globbing="false" pipelineInput="false" position="2">
<maml:name>InitializationScript</maml:name>
<maml:description>
<maml:para>指定在工作啟動之前執行的命令。請以大括號 ( { } ) 括住命令以建立指令碼區塊。
請使用此參數來準備工作執行所在的工作階段。例如,您可以使用此參數,將函數、嵌入式管理單元和模組新增至工作階段。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">scriptblock</command:parameterValue>
<dev:type>
<maml:name>scriptblock</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>無</dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="true (ByValue)" position="named">
<maml:name>InputObject</maml:name>
<maml:description>
<maml:para>指定命令的輸入。請輸入包含物件的變數,或輸入可產生物件的命令或運算式。
請在 ScriptBlock 參數的值中使用 $input 自動變數,以表示輸入物件。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">psobject</command:parameterValue>
<dev:type>
<maml:name>psobject</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue></dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="true (ByPropertyName)" position="named">
<maml:name>Name</maml:name>
<maml:description>
<maml:para>指定新工作的好記名稱。您可以使用這個名稱讓其他工作 Cmdlet (例如 Stop-Job) 識別此工作。
預設的好記名稱是 Job#,其中 "#" 是隨著每一項工作遞增的序數。</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>Job<編號></dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>RunAs32</maml:name>
<maml:description>
<maml:para>在 32 位元處理序中執行此工作。
請使用此參數來強制工作在 64 位元作業系統上的 32 位元處理序中執行。</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="true" variableLength="false" globbing="false" pipelineInput="false" position="1">
<maml:name>ScriptBlock</maml:name>
<maml:description>
<maml:para>指定要在背景工作中執行的命令。請以大括號 ( { } ) 括住命令以建立指令碼區塊。此參數為必要項。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">scriptblock</command:parameterValue>
<dev:type>
<maml:name>scriptblock</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 -->
您可以經由管道將檔案路徑輸出至 Start-Job。
</maml:para>
</maml:description>
</command:inputType>
</command:inputTypes>
<command:returnValues>
<command:returnValue>
<dev:type>
<maml:name>System.Management.Automation.RemotingJob</maml:name>
<maml:uri />
<maml:description />
</dev:type>
<maml:description>
<maml:para>
<!-- description -->
Start-Job 會傳回代表它所啟動之工作的物件。
</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>
為了在背景中執行,Start-Job 會在目前工作階段內其個別工作階段中執行。當您使用 Invoke-Command Cmdlet 在遠端電腦的工作階段中執行 Start-Job 命令時,Start-Job 會在遠端工作階段內的工作階段中執行。
</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>
start-job -scriptblock {get-process}
C:\PS> start-job -command "get-process"
Id Name State HasMoreData Location Command
--- ---- ----- ----------- -------- -------
1 Job1 Running True localhost get-process </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個命令會啟動執行 Get-Process 命令的背景工作。它會傳回內含工作相關資訊的工作物件。命令提示會立即傳回,讓您能夠在工作於背景中執行時,在工作階段中執行作業。</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>
$jobWRM = invoke-command -computerName (get-content servers.txt) -scriptblock {get-service winrm} -jobname WinRM -throttlelimit 16 -AsJob </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個命令會使用 Invoke-Command Cmdlet 及其 AsJob 參數,在多部電腦啟動執行 "get-service winrm" 命令的背景工作。因為此命令是在網路流量極大的伺服器執行,所以它會使用 Invoke-Command 的 ThrottleLimit 參數,將並行命令的數目限制為 16 個。
這個命令會使用 ComputerName 參數來指定執行工作的電腦。ComputerName 參數的值是 Get-Content 命令,這個命令會取得 Servers.txt 檔案 (網域中電腦名稱的檔案) 中的文字。
這個命令會使用 ScriptBlock 參數來指定命令,並使用 JobName 參數來指定工作的好記名稱。</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>
$j = start-job -scriptblock {get-eventlog -log system} -credential domain01\user01
C:\PS> $j | format-list -property *
HasMoreData : True
StatusMessage :
Location : localhost
Command : get-eventlog -log system
JobStateInfo : Running
Finished : System.Threading.ManualResetEvent
InstanceId : 2d9d775f-63e0-4d48-b4bc-c05d0e177f34
Id : 1
Name : Job1
ChildJobs : {Job2}
Output : {}
Error : {}
Progress : {}
Verbose : {}
Debug : {}
Warning : {}
StateChanged :
C:\PS> $j.JobStateInfo.state
Completed
C:\PS> $results = receive-job -job $j
C:\PS> $results
Index Time Type Source EventID Message
----- ---- ---- ------ ------- -------
84366 Feb 18 19:20 Information Service Control M... 7036 The description...
84365 Feb 18 19:16 Information Service Control M... 7036 The description...
84364 Feb 18 19:10 Information Service Control M... 7036 The description...
... </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這些命令會管理在 [事件檢視器] 中,從系統記錄檔取得所有事件的背景工作。該工作是在本機電腦執行。
第一個命令會使用 Start-Job Cmdlet 啟動工作。它使用 Credential 參數指定有權在電腦上執行此工作之使用者的使用者帳戶,然後再將 Start-Job 傳回的工作物件儲存在 $j 變數中。
此時,您可以在等待工作完成期間繼續執行其他作業。
第二個命令會使用管線運算子 (|),將 $j 中的工作物件傳遞給 Format-List Cmdlet。Format-List 命令會使用值為 * (所有) 的 Property 參數,在清單中顯示工作物件的所有屬性。
第三個命令會顯示 JobStateInfo 屬性的值,其中包含工作的狀態。
第四個命令會使用 Receive-Job Cmdlet 取得工作結果。它會將結果儲存在 $results 變數中。
最後一個命令會顯示 $results 變數的內容。</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>
start-job -filepath c:\scripts\sample.ps1 </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個命令會將 Sample.ps1 指令碼當做背景工作來執行。</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>
start-job -name WinRm -scriptblock {get-process winrm} </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個命令會在本機電腦執行取得 WinRM 處理序的背景工作。它會使用 ScriptBlock 參數來指定在背景工作中執行的命令,並使用 Name 參數指定新工作的好記名稱。</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>
start-job -name GetMappingFiles -initializationScript {import-module MapFunctions} -scriptblock {Get-Map -name * | set-content D:\Maps.tif} -runAs32 </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個命令會啟動收集大量資料的工作並將它儲存在 .tif 檔案中。此命令會使用 InitializationScript 參數來執行匯入所需模組的指令碼區塊。此外,它也會使用 RunAs32 參數,在 32 位元處理序中執行此工作,即使電腦具有 64 位元作業系統也一樣。</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=113405</maml:uri>
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>about_Jobs</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>about_Job_Details</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>about_Remote_Jobs</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Get-Job</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Receive-Job</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Wait-Job</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Stop-Job</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Remove-Job</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Invoke-Command</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>
Stop-Job
</command:name>
<maml:description>
<maml:para>停止 Windows PowerShell 背景工作。</maml:para>
</maml:description>
<maml:copyright>
<maml:para></maml:para>
</maml:copyright>
<command:verb>Stop</command:verb>
<command:noun>Job</command:noun>
<dev:version></dev:version>
</command:details>
<maml:description>
<maml:para>Stop-Job Cmdlet 會停止正在進行的 Windows PowerShell 背景工作。您可以使用這個 Cmdlet 停止所有工作,或是依據工作的名稱、識別碼、執行個體識別碼或狀態,或者將工作物件傳遞到 Stop-Job,以便停止選取的工作。
您可以使用 Stop-Job 停止透過 Start-Job 或透過 Invoke-Command 的 AsJob 參數所啟動的工作。停止背景工作時,Windows PowerShell 會完成擱置在該工作佇列中的所有工作,然後再結束該項工作。提交此命令之後,佇列中便不會新增任何工作。
此 Cmdlet 無法刪除背景工作。若要刪除工作,請使用 Remove-Job。</maml:para>
</maml:description>
<!-- Cmdlet syntax section-->
<command:syntax>
<command:syntaxItem>
<maml:name>Stop-Job</maml:name>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="true (ByPropertyName)" position="1">
<maml:name>InstanceId</maml:name>
<maml:description>
<maml:para>只停止具有指定之執行個體識別碼的工作。預設為所有工作。
執行個體識別碼是一種 GUID,它能夠唯一識別電腦上的工作。若要尋找工作的執行個體識別碼,請使用 Get-Job。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="true">Guid[]</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:syntaxItem>
<command:syntaxItem>
<maml:name>Stop-Job</maml:name>
<command:parameter required="true" variableLength="true" globbing="false" pipelineInput="true (ByValue, ByPropertyName)" position="1">
<maml:name>Job</maml:name>
<maml:description>
<maml:para>指定要停止的工作。請輸入包含工作的變數或可取得工作的命令。您也可以使用管線運算子將工作提交給 Stop-Job Cmdlet。根據預設,Stop-Job 會刪除目前工作階段中已經啟動的所有工作。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="true">Job[]</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:syntaxItem>
<command:syntaxItem>
<maml:name>Stop-Job</maml:name>
<command:parameter required="false" variableLength="true" globbing="true" pipelineInput="true (ByPropertyName)" position="1">
<maml:name>Name</maml:name>
<maml:description>
<maml:para>只停止具有指定之好記名稱的工作。請以逗號分隔的方式輸入工作名稱清單,或是使用萬用字元 (*) 輸入工作名稱模式。根據預設,Stop-Job 會停止目前工作階段中建立的所有工作。
由於無法保證好記名稱不會重複,因此在依名稱停止工作時,請使用 WhatIf 和 Confirm 參數。</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:syntaxItem>
<command:syntaxItem>
<maml:name>Stop-Job</maml:name>
<command:parameter required="true" variableLength="true" globbing="false" pipelineInput="true (ByPropertyName)" position="1">
<maml:name>Id</maml:name>
<maml:description>
<maml:para>停止具有指定之識別碼的工作。預設為目前工作階段中的所有工作。
識別碼是整數,可唯一識別目前工作階段內的工作。它比 InstanceId 更容易記得和輸入,但是只有在目前的工作階段中才具有唯一性。您可以輸入一個或多個識別碼 (以逗號分隔)。若要尋找工作的識別碼,請輸入 "Get-Job" 且不要指定參數。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="true">Int32[]</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:syntaxItem>
<command:syntaxItem>
<maml:name>Stop-Job</maml:name>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="true (ByPropertyName)" position="named">
<maml:name>State</maml:name>
<maml:description>
<maml:para>只停止處於指定之狀態的工作。有效的值包括 NotStarted、Running、Completed、Stopped、Failed 和 Blocked。</maml:para>
</maml:description>
<command:parameterValueGroup>
<command:parameterValue required="false" variableLength="false">NotStarted</command:parameterValue>
<command:parameterValue required="false" variableLength="false">Running</command:parameterValue>
<command:parameterValue required="false" variableLength="false">Completed</command:parameterValue>
<command:parameterValue required="false" variableLength="false">Failed</command:parameterValue>
<command:parameterValue required="false" variableLength="false">Stopped</command:parameterValue>
<command:parameterValue required="false" variableLength="false">Blocked</command:parameterValue>
</command:parameterValueGroup>
</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:syntaxItem>
</command:syntax>
<!-- Cmdlet parameter section -->
<command:parameters>
<command:parameter required="true" variableLength="true" globbing="false" pipelineInput="true (ByPropertyName)" position="1">
<maml:name>Id</maml:name>
<maml:description>
<maml:para>停止具有指定之識別碼的工作。預設為目前工作階段中的所有工作。
識別碼是整數,可唯一識別目前工作階段內的工作。它比 InstanceId 更容易記得和輸入,但是只有在目前的工作階段中才具有唯一性。您可以輸入一個或多個識別碼 (以逗號分隔)。若要尋找工作的識別碼,請輸入 "Get-Job" 且不要指定參數。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="true">Int32[]</command:parameterValue>
<dev:type>
<maml:name>Int32[]</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue></dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="true (ByPropertyName)" position="1">
<maml:name>InstanceId</maml:name>
<maml:description>
<maml:para>只停止具有指定之執行個體識別碼的工作。預設為所有工作。
執行個體識別碼是一種 GUID,它能夠唯一識別電腦上的工作。若要尋找工作的執行個體識別碼,請使用 Get-Job。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="true">Guid[]</command:parameterValue>
<dev:type>
<maml:name>Guid[]</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>Job</maml:name>
<maml:description>
<maml:para>指定要停止的工作。請輸入包含工作的變數或可取得工作的命令。您也可以使用管線運算子將工作提交給 Stop-Job Cmdlet。根據預設,Stop-Job 會刪除目前工作階段中已經啟動的所有工作。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="true">Job[]</command:parameterValue>
<dev:type>
<maml:name>Job[]</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue></dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="true" pipelineInput="true (ByPropertyName)" position="1">
<maml:name>Name</maml:name>
<maml:description>
<maml:para>只停止具有指定之好記名稱的工作。請以逗號分隔的方式輸入工作名稱清單,或是使用萬用字元 (*) 輸入工作名稱模式。根據預設,Stop-Job 會停止目前工作階段中建立的所有工作。
由於無法保證好記名稱不會重複,因此在依名稱停止工作時,請使用 WhatIf 和 Confirm 參數。</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="false" variableLength="false" globbing="false" pipelineInput="true (ByPropertyName)" position="named">
<maml:name>State</maml:name>
<maml:description>
<maml:para>只停止處於指定之狀態的工作。有效的值包括 NotStarted、Running、Completed、Stopped、Failed 和 Blocked。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">JobState</command:parameterValue>
<dev:type>
<maml:name>JobState</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.Management.Automation.RemotingJob</maml:name>
<maml:uri />
<maml:description />
</dev:type>
<maml:description>
<maml:para>
<!-- description -->
您可以經由管道將工作物件輸出至 Stop-Job。
</maml:para>
</maml:description>
</command:inputType>
</command:inputTypes>
<command:returnValues>
<command:returnValue>
<dev:type>
<maml:name>無或 System.Management.Automation.RemotingJob</maml:name>
<maml:uri />
<maml:description />
</dev:type>
<maml:description>
<maml:para>
<!-- description -->
當您使用 PassThru 參數時,Stop-Job 會傳回工作物件。否則,這個 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>
</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>
$s = new-pssession -computername Server01 -credential domain01\admin02
C:\PS> $j = invoke-command -session $s -scriptblock {start-job -scriptblock {get-eventlog system}}
C:\PS> invoke-command -session $s -scriptblock {param($j) stop-job -job $j} -ArgumentList $j </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>在這個範例中,會示範如何使用 Stop-Job Cmdlet 停止正在遠端電腦執行的工作。
因為該工作是使用 Invoke-Command 在遠端執行 Start-Job 命令來啟動,所以工作物件會儲存在遠端電腦,而且您必須使用另一個 Invoke-Command 命令在遠端執行 Stop-Job 命令。如需遠端背景工作的詳細資訊,請參閱 about_Remote_Jobs。
第一個命令會在 Server01 電腦建立 Windows PowerShell 工作階段 (PSSession),並將此工作階段物件儲存在 $s 變數中。這個命令會使用網域系統管理員的認證。
第二個命令會使用 Invoke-Command Cmdlet 在工作階段中執行 Start-Job 命令。工作中的命令會取得系統事件記錄檔中的所有事件。產生的工作物件會儲存在 $j 變數中。
第三個命令會停止工作。它會使用 Invoke-Command Cmdlet,在 Server01 的 PSSession 中執行 Stop-Job 命令。因為工作物件儲存在本機電腦上的變數 $j 中,所以命令會使用 "param" 關鍵字在命令中宣告區域變數,並使用 ArgumentList 參數來提供變數的值。
當此命令執行完成時,雖然工作會停止,但是 $s 中的 PSSession 仍然可供使用。</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>
stop-job -state failed </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個命令會停止 State 值為 "Failed" 的所有工作。</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>
stop-job -name job1 </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個命令會停止 Job1 背景工作。</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>
stop-job -id 1, 3, 4 </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>
-------------------------- 範例 5 --------------------------
</maml:title>
<maml:introduction>
<maml:para>C:\PS></maml:para>
</maml:introduction>
<dev:code>
get-job | stop-job </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>
-------------------------- 範例 6 --------------------------
</maml:title>
<maml:introduction>
<maml:para>C:\PS></maml:para>
</maml:introduction>
<dev:code>
stop-job -state blocked </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個命令會停止工作狀態為 "Blocked" 的所有工作。</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>
-------------------------- 範例 7 --------------------------
</maml:title>
<maml:introduction>
<maml:para>C:\PS></maml:para>
</maml:introduction>
<dev:code>
get-job | format-table ID, Name, Command, @{Label="State";Expression={$_.jobstateinfo.state}}, I
nstanceID -auto
Id Name Command State InstanceId
-- ---- ------- ----- ----------
1 Job1 start-service schedule Running 05abb67a-2932-4bd5-b331-c0254b8d9146
3 Job3 start-service schedule Running c03cbd45-19f3-4558-ba94-ebe41b68ad03
5 Job5 get-service s* Blocked e3bbfed1-9c53-401a-a2c3-a8db34336adf
C:\PS> stop-job -instanceid e3bbfed1-9c53-401a-a2c3-a8db34336adf </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這些命令示範如何依據執行個體識別碼來停止工作。
第一個命令會使用 Get-Job 命令取得目前工作階段中的工作。這個命令會使用管線運算子 (|) 將工作傳送到 Format-Table,該命令會顯示一份表格,列出每項工作的指定屬性。表格中包含每一項工作的執行個體識別碼。它會使用計算屬性來顯示工作狀態。
第二個命令會使用 Stop-Job 命令搭配 InstanceID 參數,停止所選取的工作。</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>
-------------------------- 範例 8 --------------------------
</maml:title>
<maml:introduction>
<maml:para>C:\PS></maml:para>
</maml:introduction>
<dev:code>
$j = invoke-command -computername Server01 -scriptblock {get-eventlog system} -asjob
C:\PS> $j | stop-job -passthru
Id Name State HasMoreData Location Command
-- ---- ---- ----------- -------- -------
5 Job5 Stopped True judithh-tablet get-eventlog system </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>在這個範例中,會示範如何使用 Stop-Job Cmdlet 停止正在遠端電腦執行的工作。
因為該工作是使用 Invoke-Command 的 AsJob 參數啟動,所以即使工作是在遠端電腦執行,工作物件仍然位於本機電腦。因此,您可以使用本機 Stop-Job 命令停止工作。
第一個命令會使用 Invoke-Command Cmdlet,在 Server01 電腦上啟動背景工作。這個命令會使用 AsJob 參數,將遠端命令當做背景工作來執行,
這個命令會傳回工作物件 (與 Start-Job 傳回的工作物件相同),再將工作物件儲存在 $j 變數中。
第二個命令會使用管線運算子,將 $j 變數中的工作傳送到 Stop-Job。這個命令會使用 PassThru 參數來指示 Stop-Job 傳回工作物件。工作物件顯示確認工作的 State 屬性值是 "Stopped"。
如需遠端背景工作的詳細資訊,請參閱 about_Remote_Jobs。
</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=113413</maml:uri>
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>about_Jobs</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>about_Job_Details</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>about_Remote_Jobs</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Start-Job</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Get-Job</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Receive-Job</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Wait-Job</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Remove-Job</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Invoke-Command</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>
Test-ModuleManifest
</command:name>
<maml:description>
<maml:para>確認模組資訊清單檔案是否正確描述模組的內容。</maml:para>
</maml:description>
<maml:copyright>
<maml:para></maml:para>
</maml:copyright>
<command:verb>Test</command:verb>
<command:noun>ModuleManifest</command:noun>
<dev:version></dev:version>
</command:details>
<maml:description>
<maml:para>Test-ModuleManifest Cmdlet 會確認模組資訊清單 (.psd1) 檔案所列出的檔案確實存在指定的路徑中。
此 Cmdlet 是專為協助模組作者測試其資訊清單檔案而設計。模組使用者也可以在指令碼和命令中使用這個 Cmdlet,在執行依存於模組的指令碼之前偵測錯誤。
Test-ModuleManifest Cmdlet 會傳回表示模組的物件 (與 Get-Module 傳回的物件屬於相同類型)。如果有檔案不在資訊清單所指定的位置中,此 Cmdlet 也會針對每個遺失的檔案產生一項錯誤。</maml:para>
</maml:description>
<!-- Cmdlet syntax section-->
<command:syntax>
<command:syntaxItem>
<maml:name>Test-ModuleManifest</maml:name>
<command:parameter required="true" variableLength="false" globbing="false" pipelineInput="true (ByValue, ByPropertyName)" position="1">
<maml:name>Path</maml:name>
<maml:description>
<maml:para>指定模組資訊清單檔案的路徑。請輸入副檔名為 .psd1 之模組資訊清單檔案的路徑 (選擇項) 和名稱。預設位置為目前目錄。此參數為必要項。參數名稱 ("Path") 為選擇項。您也可以經由管道將路徑輸出至 Test-ModuleManifest。</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="true" variableLength="false" globbing="false" pipelineInput="true (ByValue, ByPropertyName)" position="1">
<maml:name>Path</maml:name>
<maml:description>
<maml:para>指定模組資訊清單檔案的路徑。請輸入副檔名為 .psd1 之模組資訊清單檔案的路徑 (選擇項) 和名稱。預設位置為目前目錄。此參數為必要項。參數名稱 ("Path") 為選擇項。您也可以經由管道將路徑輸出至 Test-ModuleManifest。</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 -->
您可以經由管道將模組資訊清單的路徑輸出至 Test-ModuleManifest。
</maml:para>
</maml:description>
</command:inputType>
</command:inputTypes>
<command:returnValues>
<command:returnValue>
<dev:type>
<maml:name>System.Management.Automation.PSModuleInfo</maml:name>
<maml:uri />
<maml:description />
</dev:type>
<maml:description>
<maml:para>
<!-- description -->
Test-ModuleManifest 會傳回表示模組的 PSModuleInfo 物件。即使資訊清單發生錯誤,它還是會傳回這個物件。
</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>
test-ModuleManifest -path $pshome\Modules\TestModule.psd1 </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個命令會測試 TestModule.psd1 模組資訊清單。</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>
"$pshome\Modules\TestModule.psd1" | test-modulemanifest
Test-ModuleManifest : The specified type data file 'C:\Windows\System32\Wi
ndowsPowerShell\v1.0\Modules\TestModule\TestTypes.ps1xml' could not be pro
cessed because the file was not found. Please correct the path and try aga
in.
At line:1 char:34
+ "$pshome\Modules\TestModule.psd1" | test-modulemanifest <<<<
+ CategoryInfo : ResourceUnavailable: (C:\Windows\System32\Win
dowsPowerShell\v1.0\Modules\TestModule\TestTypes.ps1xml:String) [Test-Modul
eManifest], FileNotFoundException
+ FullyQualifiedErrorId : Modules_TypeDataFileNotFound,Microsoft.
PowerShell.Commands.TestModuleManifestCommandName
Name : TestModule
Path : C:\Windows\system32\WindowsPowerShell\v1.0\Modules\Test
Module\TestModule.psd1
Description :
Guid : 6f0f1387-cd25-4902-b7b4-22cff6aefa7b
Version : 1.0
ModuleBase : C:\Windows\system32\WindowsPowerShell\v1.0\Modules\Test
Module
ModuleType : Manifest
PrivateData :
AccessMode : ReadWrite
ExportedAliases : {}
ExportedCmdlets : {}
ExportedFunctions : {}
ExportedVariables : {}
NestedModules : {}
</dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個命令會使用管線運算子 (|),將路徑字串傳送到 Test-ModuleManifest。
命令輸出顯示測試失敗,原因是找不到資訊清單中列出的 TestTypes.ps1xml 檔案。</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>
function Bool-ModuleManifest ($path)
{$a = dir $path | test-modulemanifest -erroraction SilentlyContinue; $?}
</dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個函數與 Test-ModuleManifest 類似,但是前者會傳回布林值,其中 "True" 表示資訊清單通過測試,"False" 則表示未通過。
這個函數會使用 Get-ChildItem Cmdlet (別名為 dir) 取得 $path 變數所指定的模組資訊清單。它會使用管線運算子 (|),將檔案物件傳遞給 Test-ModuleManifest Cmdlet。
Test-ModuleManifest 命令會使用值為 SilentlyContinue 的 ErrorAction 一般參數,隱藏此命令產生的任何錯誤。它也會將 Test-ModuleManifest 傳回的 PSModuleInfo 物件儲存在 $a 變數中,所以這個物件並不會顯示。
接著,在另一個命令中 (分號 [;] 是命令分隔符號),它會顯示 $? 自動變數的值,如果先前的命令沒有產生任何錯誤便會傳回 "True",否則會傳回 "False"。
您可以在條件陳述式中使用這個函數,例如可能放在 Import-Module 命令或使用模組之命令前面的條件陳述式。</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=141557</maml:uri>
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Import-Module</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Get-Module</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>New-Module</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Remove-Module</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Export-ModuleMember</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>New-ModuleManifest</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>about_Modules</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>
Unregister-PSSessionConfiguration
</command:name>
<maml:description>
<maml:para>從電腦中刪除已註冊的工作階段設定。</maml:para>
</maml:description>
<maml:copyright>
<maml:para></maml:para>
</maml:copyright>
<command:verb>Unregister</command:verb>
<command:noun>PSSessionConfiguration</command:noun>
<dev:version></dev:version>
</command:details>
<maml:description>
<maml:para>Unregister-PSSessionConfiguration Cmdlet 會從電腦中刪除已註冊的工作階段設定。這是進階的 Cmdlet,適合系統管理員用來管理使用者的自訂工作階段設定。
如果您不小心刪除了預設的 Microsoft.PowerShell 或 Microsoft.PowerShell32 工作階段設定,請使用 Enable-PSRemoting Cmdlet 來還原它們。</maml:para>
</maml:description>
<!-- Cmdlet syntax section-->
<command:syntax>
<command:syntaxItem>
<maml:name>Unregister-PSSessionConfiguration</maml:name>
<command:parameter required="true" variableLength="false" globbing="false" pipelineInput="true (ByPropertyName)" position="1">
<maml:name>Name</maml:name>
<maml:description>
<maml:para>指定要刪除之工作階段設定的名稱。請輸入一個或多個設定名稱。允許使用萬用字元。此參數為必要項。
您也可以經由管道將工作階段設定物件輸出至 Unregister-PSSessionConfiguration。</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>Force</maml:name>
<maml:description>
<maml:para>抑制所有使用者提示,並重新啟動 WinRM 服務,而不進行提示。重新啟動服務可讓設定變更生效。
若要防止進行重新啟動並抑制重新啟動的提示,請使用 NoServiceRestart 參數。</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>NoServiceRestart</maml:name>
<maml:description>
<maml:para>不重新啟動 WinRM 服務,並抑制重新啟動服務的提示。
根據預設,當您輸入 Unregister-PSSessionConfiguration 命令時,系統就會提示您重新啟動 WinRM 服務,讓變更生效。在重新啟動 WinRM 服務之前,使用者仍然可以使用取消註冊的工作階段設定,即使 Get-PSSessionConfiguration 找不到此設定也一樣。
若要重新啟動 WinRM 服務而不進行提示,請使用 Force 參數。若要手動重新啟動 WinRM 服務,請使用 Restart-Service 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:syntaxItem>
</command:syntax>
<!-- Cmdlet parameter section -->
<command:parameters>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>Force</maml:name>
<maml:description>
<maml:para>抑制所有使用者提示,並重新啟動 WinRM 服務,而不進行提示。重新啟動服務可讓設定變更生效。
若要防止進行重新啟動並抑制重新啟動的提示,請使用 NoServiceRestart 參數。</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="false" globbing="false" pipelineInput="true (ByPropertyName)" position="1">
<maml:name>Name</maml:name>
<maml:description>
<maml:para>指定要刪除之工作階段設定的名稱。請輸入一個或多個設定名稱。允許使用萬用字元。此參數為必要項。
您也可以經由管道將工作階段設定物件輸出至 Unregister-PSSessionConfiguration。</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>NoServiceRestart</maml:name>
<maml:description>
<maml:para>不重新啟動 WinRM 服務,並抑制重新啟動服務的提示。
根據預設,當您輸入 Unregister-PSSessionConfiguration 命令時,系統就會提示您重新啟動 WinRM 服務,讓變更生效。在重新啟動 WinRM 服務之前,使用者仍然可以使用取消註冊的工作階段設定,即使 Get-PSSessionConfiguration 找不到此設定也一樣。
若要重新啟動 WinRM 服務而不進行提示,請使用 Force 參數。若要手動重新啟動 WinRM 服務,請使用 Restart-Service 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="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.Commands.PSSessionConfigurationCommands#PSSessionConfiguration</maml:name>
<maml:uri />
<maml:description />
</dev:type>
<maml:description>
<maml:para>
<!-- description -->
您可以經由管道將工作階段設定物件從 Get-PSSessionConfiguration 輸出至 Unregister-PSSessionConfiguration。
</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>
若要在 Windows Vista、Windows Server 2008 和更新版的 Windows 上執行這個 Cmdlet,您必須使用 [以系統管理員身分執行] 選項啟動 Windows PowerShell。
</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>
unregister-pssessionconfiguration -name MaintenanceShell </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個命令會從電腦中刪除 MaintenanceShell 工作階段設定。</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>
unregister-pssessionconfiguration -maintenanceShell -force </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個命令會從電腦中刪除 MaintenanceShell 工作階段設定。此命令會使用 Force 參數來抑制所有使用者訊息並且重新啟動 WinRM 服務,而不進行提示。</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>
unregister-pssessionconfiguration -name *
C:\PS> get-pssessionconfiguration -name * | unregister-pssessionconfiguration </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>
-------------------------- 範例 4 --------------------------
</maml:title>
<maml:introduction>
<maml:para>C:\PS></maml:para>
</maml:introduction>
<dev:code>
unregister-pssessionconfiguration -name maintenanceShell -noServiceRestart
C:\PS> get-pssessionconfiguration -name maintenanceShell
Get-PSSessionConfiguration -name maintenanceShell : No Session Configuration matches criteria "maintenanceShell".
+ CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException
+ FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException
C:\PS> new-pssession -configurationName MaintenanceShell
Id Name ComputerName State Configuration Availability
-- ---- ------------ ----- ------------- ------------
1 Session1 localhost Opened MaintenanceShell Available
C:\PS> restart-service winrm
C:\PS> new-pssession -configurationName MaintenanceShell
[localhost] Connecting to remote server failed with the following error message : The WS-Management service cannot process the request. The resource
URI (http://schemas.microsoft.com/powershell/MaintenanceShell) was not found in the WS-Management catalog. The catalog contains the metadata that describes resour
ces, or logical endpoints. For more information, see the about_Remote_Troubleshooting Help topic.
+ CategoryInfo : OpenError: (System.Manageme....RemoteRunspace:RemoteRunspace) [], PSRemotingTransportException
+ FullyQualifiedErrorId : PSSessionOpenFailed
</dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個範例會示範使用 Unregister-PSSessionConfiguration 之 NoServiceRestart 參數的作用。這個參數的設計目的是要防止服務重新啟動,因為重新啟動會中斷電腦上的任何工作階段。
第一個命令會使用 Unregister-PSSessionConfiguration Cmdlet 來刪除 MaintenanceShell 工作階段設定。不過,因為此命令使用了 NoServiceRestart 參數,所以 WinRM 服務不會重新啟動,而且變更尚未完全生效。
第二個命令會使用 Get-PSSessionConfiguration Cmdlet 來取得 MaintenanceShell 工作階段。因為此工作階段已經從 WS-Management 資源表格中移除,所以 Get-PSSession 無法傳回此工作階段。
第三個命令會使用 New-PSSession Cmdlet,在本機電腦上建立使用 MaintenanceShell 設定的工作階段。此命令會執行成功。
第四個命令會使用 Restart-Service Cmdlet 來重新啟動 WinRM 服務。
第五個命令會再次使用 New-PSSession Cmdlet 來建立使用 MaintenanceShell 設定的工作階段。不過,這次工作階段會失敗,因為您已經刪除 MaintenanceShell 設定。</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=144308</maml:uri>
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>about_Session_Configurations</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Disable-PSSessionConfiguration</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Enable-PSSessionConfiguration</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Get-PSSessionConfiguration</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Register-PSSessionConfiguration</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Set-PSSessionConfiguration</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>WS-Management Provider</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>
Wait-Job
</command:name>
<maml:description>
<maml:para>隱藏命令提示字元,直到在工作階段中執行的一項或所有 Windows PowerShell 背景工作完成為止。</maml:para>
</maml:description>
<maml:copyright>
<maml:para></maml:para>
</maml:copyright>
<command:verb>Wait</command:verb>
<command:noun>Job</command:noun>
<dev:version></dev:version>
</command:details>
<maml:description>
<maml:para>Wait-Job Cmdlet 會等待 Windows PowerShell 背景工作完成後,再顯示命令提示字元。您可以等到任一背景工作完成,或是等到所有背景工作全都完成,並設定工作的等待時間上限。
您可以使用 Wait-Job 取得透過 Start-Job 或透過 Invoke-Command 的 AsJob 參數所啟動的背景工作。
當工作中的命令完成之後,Wait-Job 會顯示命令提示字元,並傳回工作物件,讓您可以經由管道將它輸出至其他命令。</maml:para>
</maml:description>
<!-- Cmdlet syntax section-->
<command:syntax>
<command:syntaxItem>
<maml:name>Wait-Job</maml:name>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="true (ByPropertyName)" position="1">
<maml:name>InstanceId</maml:name>
<maml:description>
<maml:para>等待具有指定之執行個體識別碼的工作。預設為所有工作。
執行個體識別碼是一種 GUID,它能夠唯一識別電腦上的工作。若要尋找工作的執行個體識別碼,請使用 Get-Job。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="true">Guid[]</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>Any</maml:name>
<maml:description>
<maml:para>於任一工作完成時顯示命令提示字元 (並傳回工作物件)。Wait-Job 預設會等到指定的所有工作都完成後,再顯示提示字元。</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>Timeout</maml:name>
<maml:description>
<maml:para>決定每一項背景工作的等待時間上限,以秒為單位。預設值為 -1,表示無論執行時間多長,都會等到工作執行完成。在提交 Wait-Job 命令 (而非 Start-Job 命令) 後就會開始計時。
如果超過這個時間,即使工作仍在執行中,還是會結束等候且傳回命令提示字元,並且不會顯示任何錯誤訊息。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">int</command:parameterValue>
</command:parameter>
</command:syntaxItem>
<command:syntaxItem>
<maml:name>Wait-Job</maml:name>
<command:parameter required="true" variableLength="true" globbing="false" pipelineInput="true (ByValue, ByPropertyName)" position="1">
<maml:name>Job</maml:name>
<maml:description>
<maml:para>等待指定的工作。請輸入包含工作物件的變數,或輸入可取得工作物件的命令。您也可以使用管線運算子,將工作物件傳送到 Wait-Job Cmdlet。根據預設,Wait-Job 會等待目前工作階段中建立的所有工作。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="true">Job[]</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>Any</maml:name>
<maml:description>
<maml:para>於任一工作完成時顯示命令提示字元 (並傳回工作物件)。Wait-Job 預設會等到指定的所有工作都完成後,再顯示提示字元。</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>Timeout</maml:name>
<maml:description>
<maml:para>決定每一項背景工作的等待時間上限,以秒為單位。預設值為 -1,表示無論執行時間多長,都會等到工作執行完成。在提交 Wait-Job 命令 (而非 Start-Job 命令) 後就會開始計時。
如果超過這個時間,即使工作仍在執行中,還是會結束等候且傳回命令提示字元,並且不會顯示任何錯誤訊息。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">int</command:parameterValue>
</command:parameter>
</command:syntaxItem>
<command:syntaxItem>
<maml:name>Wait-Job</maml:name>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="true (ByPropertyName)" position="1">
<maml:name>Name</maml:name>
<maml:description>
<maml:para>等待具有指定之好記名稱的工作。</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>Any</maml:name>
<maml:description>
<maml:para>於任一工作完成時顯示命令提示字元 (並傳回工作物件)。Wait-Job 預設會等到指定的所有工作都完成後,再顯示提示字元。</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>Timeout</maml:name>
<maml:description>
<maml:para>決定每一項背景工作的等待時間上限,以秒為單位。預設值為 -1,表示無論執行時間多長,都會等到工作執行完成。在提交 Wait-Job 命令 (而非 Start-Job 命令) 後就會開始計時。
如果超過這個時間,即使工作仍在執行中,還是會結束等候且傳回命令提示字元,並且不會顯示任何錯誤訊息。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">int</command:parameterValue>
</command:parameter>
</command:syntaxItem>
<command:syntaxItem>
<maml:name>Wait-Job</maml:name>
<command:parameter required="true" variableLength="true" globbing="false" pipelineInput="true (ByPropertyName)" position="1">
<maml:name>Id</maml:name>
<maml:description>
<maml:para>等待具有指定之識別碼的工作。
識別碼是整數,可唯一識別目前工作階段內的工作。它比 InstanceId 更容易記得和輸入,但是只有在目前的工作階段中才具有唯一性。您可以輸入一個或多個識別碼 (以逗號分隔)。若要尋找工作的識別碼,請輸入 "Get-Job" 且不要指定參數。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="true">Int32[]</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>Any</maml:name>
<maml:description>
<maml:para>於任一工作完成時顯示命令提示字元 (並傳回工作物件)。Wait-Job 預設會等到指定的所有工作都完成後,再顯示提示字元。</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>Timeout</maml:name>
<maml:description>
<maml:para>決定每一項背景工作的等待時間上限,以秒為單位。預設值為 -1,表示無論執行時間多長,都會等到工作執行完成。在提交 Wait-Job 命令 (而非 Start-Job 命令) 後就會開始計時。
如果超過這個時間,即使工作仍在執行中,還是會結束等候且傳回命令提示字元,並且不會顯示任何錯誤訊息。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">int</command:parameterValue>
</command:parameter>
</command:syntaxItem>
<command:syntaxItem>
<maml:name>Wait-Job</maml:name>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="true (ByPropertyName)" position="named">
<maml:name>State</maml:name>
<maml:description>
<maml:para>等待具有指定之狀態的工作。有效的值包括 NotStarted、Running、Completed、Stopped、Failed 和 Blocked。</maml:para>
</maml:description>
<command:parameterValueGroup>
<command:parameterValue required="false" variableLength="false">NotStarted</command:parameterValue>
<command:parameterValue required="false" variableLength="false">Running</command:parameterValue>
<command:parameterValue required="false" variableLength="false">Completed</command:parameterValue>
<command:parameterValue required="false" variableLength="false">Failed</command:parameterValue>
<command:parameterValue required="false" variableLength="false">Stopped</command:parameterValue>
<command:parameterValue required="false" variableLength="false">Blocked</command:parameterValue>
</command:parameterValueGroup>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>Any</maml:name>
<maml:description>
<maml:para>於任一工作完成時顯示命令提示字元 (並傳回工作物件)。Wait-Job 預設會等到指定的所有工作都完成後,再顯示提示字元。</maml:para>
</maml:description>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>Timeout</maml:name>
<maml:description>
<maml:para>決定每一項背景工作的等待時間上限,以秒為單位。預設值為 -1,表示無論執行時間多長,都會等到工作執行完成。在提交 Wait-Job 命令 (而非 Start-Job 命令) 後就會開始計時。
如果超過這個時間,即使工作仍在執行中,還是會結束等候且傳回命令提示字元,並且不會顯示任何錯誤訊息。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">int</command:parameterValue>
</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>Any</maml:name>
<maml:description>
<maml:para>於任一工作完成時顯示命令提示字元 (並傳回工作物件)。Wait-Job 預設會等到指定的所有工作都完成後,再顯示提示字元。</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>Id</maml:name>
<maml:description>
<maml:para>等待具有指定之識別碼的工作。
識別碼是整數,可唯一識別目前工作階段內的工作。它比 InstanceId 更容易記得和輸入,但是只有在目前的工作階段中才具有唯一性。您可以輸入一個或多個識別碼 (以逗號分隔)。若要尋找工作的識別碼,請輸入 "Get-Job" 且不要指定參數。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="true">Int32[]</command:parameterValue>
<dev:type>
<maml:name>Int32[]</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue></dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="true (ByPropertyName)" position="1">
<maml:name>InstanceId</maml:name>
<maml:description>
<maml:para>等待具有指定之執行個體識別碼的工作。預設為所有工作。
執行個體識別碼是一種 GUID,它能夠唯一識別電腦上的工作。若要尋找工作的執行個體識別碼,請使用 Get-Job。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="true">Guid[]</command:parameterValue>
<dev:type>
<maml:name>Guid[]</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>Job</maml:name>
<maml:description>
<maml:para>等待指定的工作。請輸入包含工作物件的變數,或輸入可取得工作物件的命令。您也可以使用管線運算子,將工作物件傳送到 Wait-Job Cmdlet。根據預設,Wait-Job 會等待目前工作階段中建立的所有工作。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="true">Job[]</command:parameterValue>
<dev:type>
<maml:name>Job[]</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue></dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="true (ByPropertyName)" position="1">
<maml:name>Name</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="true (ByPropertyName)" position="named">
<maml:name>State</maml:name>
<maml:description>
<maml:para>等待具有指定之狀態的工作。有效的值包括 NotStarted、Running、Completed、Stopped、Failed 和 Blocked。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">JobState</command:parameterValue>
<dev:type>
<maml:name>JobState</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>Timeout</maml:name>
<maml:description>
<maml:para>決定每一項背景工作的等待時間上限,以秒為單位。預設值為 -1,表示無論執行時間多長,都會等到工作執行完成。在提交 Wait-Job 命令 (而非 Start-Job 命令) 後就會開始計時。
如果超過這個時間,即使工作仍在執行中,還是會結束等候且傳回命令提示字元,並且不會顯示任何錯誤訊息。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">int</command:parameterValue>
<dev:type>
<maml:name>int</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.Management.Automation.RemotingJob</maml:name>
<maml:uri />
<maml:description />
</dev:type>
<maml:description>
<maml:para>
<!-- description -->
您可以經由管道將工作物件輸出至 Wait-Job。
</maml:para>
</maml:description>
</command:inputType>
</command:inputTypes>
<command:returnValues>
<command:returnValue>
<dev:type>
<maml:name>System.Management.Automation.RemotingJob</maml:name>
<maml:uri />
<maml:description />
</dev:type>
<maml:description>
<maml:para>
<!-- description -->
Wait-Job 會傳回代表已完成之工作的工作物件。如果等候結束的原因是已超過 Timeout 參數的值,Wait-Job 就不會傳回任何物件。
</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>
get-job | wait-job </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>
$s = new-pssession server01, server02, server03
C:\PS> invoke-command -session $s -scriptblock {start-job -name Date1 -scriptblock {get-date}}
C:\PS> $done = invoke-command -session $s -command {wait-job -name Date1}
C:\PS> $done.count
3 </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>在這個範例中,會示範如何使用 Wait-Job Cmdlet,處理利用 Start-Job Cmdlet 在遠端電腦啟動的工作。Start-Job 和 Wait-Job 命令都是利用 Invoke-Command Cmdlet 提交到遠端電腦。
範例中使用 Wait-Job 判斷在三台不同電腦上,當做背景工作執行的 Get-Date 命令是否已完成。
第一個命令會分別在三台遠端電腦上建立 Windows PowerShell 工作階段 (PSSession),並將它們儲存在 $s 變數中。
第二個命令會使用 Invoke-Command Cmdlet,在 $s 中的三個工作階段內分別執行 Start-Job 命令。所有的工作都命名為 Date1。
第三個命令會使用 Invoke-Command Cmdlet 執行 Wait-Job 命令,並等待每部電腦的 Date1 工作執行完成,然後將產生的工作物件集合 (陣列) 儲存在 $done 變數中。
第四個命令會使用 $done 變數中工作物件陣列的 Count 屬性判斷已完成的工作數目。</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>
$s = new-pssession (get-content machines.txt)
C:\PS> $c = 'get-eventlog -log system | where {$_.EntryType -eq "error" -and $_.Source -eq "LSASRV"} | out-file errors.txt'
C:\PS> invoke-command -session $s -scriptblock {param($c)start-job -scriptblock {$c}} -ArgumentList $c
C:\PS> invoke-command -session $s -scriptblock {wait-job -any} </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個範例會使用 Wait-Job 的 Any 陣列,判斷目前工作階段裡正在執行的許多背景工作中,第一項工作完成的時間。範例中也會示範如何使用 Wait-Job Cmdlet 等待遠端工作執行完成。
第一個命令會在 Machines.txt 檔案中列出的每一部電腦建立 PSSession,並將這些 PSSession 儲存在 $s 變數中。這個命令會使用 Get-Content Cmdlet 取得該檔案的內容。Get-Content 命令放在括號內,確保它會在 New-PSSession 命令之前執行。
第二個命令會將 Get-EventLog 命令字串 (置於引號內) 儲存在 $c 變數中。
第三個命令會使用 Invoke-Command Cmdlet,在 $s 中的每個工作階段內執行 Start-Job 命令。Start-Job 命令會啟動一項背景工作,此工作會執行 $c 中的命令。
因為 $c 變數位於本機電腦上,所以此命令會使用 "param" 關鍵字在命令中宣告區域變數,並使用 ArgumentList 參數提供這些變數的值。
第四個命令會使用 Invoke-Command Cmdlet,在工作階段中執行 Wait-Job 命令。它會使用 Wait-Job 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>
-------------------------- 範例 4 --------------------------
</maml:title>
<maml:introduction>
<maml:para>C:\PS></maml:para>
</maml:introduction>
<dev:code>
$s = new-pssession Server01, Server02, Server03
C:\PS> $jobs = invoke-command -session $s -scriptblock {start-job -script {get-date}}
C:\PS> $done = invoke-command -session $s -scriptblock {wait-job -timeout 30} </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>在這個範例中,會示範如何使用 Wait-Job 的 Timeout 參數,設定在遠端電腦執行之工作的等待時間上限。
第一個命令會分別在三台遠端電腦 (Server01、Server02 和 Server03) 上建立 PSSession,並將這些 PSSession 儲存在 $s 變數中。
第二個命令會使用 Invoke-Command Cmdlet,在 $s 中的每個 PSSession 內執行 Start-Job 命令。它會將產生的工作物件儲存在 $jobs 變數中。
第三個命令會使用 Invoke-Command Cmdlet,在 $s 中的每個 PSSessions 內執行 Wait-Job 命令。Wait-Job 命令會判斷所有的命令是否都已在 30 秒內執行完成。它會使用值為 30 (秒) 的 Timeout 參數來建立等待時間上限,並將命令的結果儲存在 $done 變數中。
在本例中,經過 30 秒之後,只有 Server02 電腦上的命令執行完成。Wait-Job 會結束等候、顯示命令提示字元,並傳回表示已完成之工作的物件。
$done 變數包含表示在 Server02 執行之工作的工作物件。</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>
wait-job -id 1,2,5 -any </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>
-------------------------- 範例 6 --------------------------
</maml:title>
<maml:introduction>
<maml:para>C:\PS></maml:para>
</maml:introduction>
<dev:code>
wait-job -name DailyLog -timeout 120 </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個命令會等待 120 秒 (兩分鐘),讓 DailyLog 工作完成。如果工作未能在接下來的兩分鐘內完成,命令提示字元還是會傳回,而且工作也會繼續在背景執行。</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>
-------------------------- 範例 7 --------------------------
</maml:title>
<maml:introduction>
<maml:para>C:\PS></maml:para>
</maml:introduction>
<dev:code>
wait-job -name Job3 </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>此 Wait-Job 命令會使用工作名稱識別要等待的工作名稱。</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>
-------------------------- 範例 8 --------------------------
</maml:title>
<maml:introduction>
<maml:para>C:\PS></maml:para>
</maml:introduction>
<dev:code>
C:\PS> $j = start-job -script {get-childitem *.ps1| where {$_lastwritetime -gt ((get-date) - (new-timespan -days 7))}}
C:\PS> $j | wait-job </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>在這個範例中,會示範如何使用 Wait-Job Cmdlet,處理利用 Start-Job Cmdlet 在本機電腦啟動的工作。
這些命令會啟動一項工作,取得前一週新增或更新的 Windows PowerShell 指令碼檔案。
第一個命令會使用 Start-Job Cmdlet,在本機電腦啟動背景工作。該工作會執行 Get-ChildItem 命令,以取得前一週新增或更新,而且副檔名為 ".ps1" 的所有檔案。
第三個命令會使用 Wait-Job 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>
-------------------------- 範例 9 --------------------------
</maml:title>
<maml:introduction>
<maml:para>C:\PS></maml:para>
</maml:introduction>
<dev:code>
$s = new-pssession Server01, Server02, Server03
C:\PS> $j = invoke-command -session $s -scriptblock {get-process} -asjob
C:\PS> $j | wait-job </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>在這個範例中,會示範如何使用 Wait-Job Cmdlet 處理利用 Invoke-Command Cmdlet 的 AsJob 參數在遠端電腦啟動的工作。使用 AsJob 時,即使工作是在遠端電腦執行,但仍是在本機電腦建立工作,而且結果也會自動傳回到本機電腦。
範例中使用 Wait-Job 判斷在三部遠端電腦之執行階段中執行的 Get-Process 命令是否已完成。
第一個命令會在三台電腦上建立 PSSession,並將它們儲存在 $s 變數中。
第二個命令會使用 Invoke-Command Cmdlet,在 $s 中的三個 PSSession 內分別執行 Get-Process 命令。這個命令會使用 AsJob 參數,將命令當做背景工作以非同步方式執行。與使用 Start-Job 啟動的工作一樣,這個命令會傳回工作物件,而且會將工作物件儲存在 $j 變數中。
第三個命令會使用管線運算子 (|),將 $j 中的工作物件傳送到 Wait-Job Cmdlet。請注意,此範例不需要 Invoke-Command 命令,因為工作是位於本機電腦。</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>
-------------------------- 範例 10 --------------------------
</maml:title>
<maml:introduction>
<maml:para>C:\PS></maml:para>
</maml:introduction>
<dev:code>
get-job
Id Name State HasMoreData Location Command
-- ---- ----- ----------- -------- -------
1 Job1 Completed True localhost,server01.. get-service
4 Job4 Completed True localhost dir | where
C:\PS> wait-job -id 1 </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個命令會等待 ID 值為 1 的工作。
</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=113422</maml:uri>
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>about_Jobs</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>about_Job_Details</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>about_Remote_Jobs</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Start-Job</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Get-Job</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Receive-Job</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Stop-Job</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Remove-Job</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Invoke-Command</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>
Where-Object
</command:name>
<maml:description>
<maml:para>建立篩選器來控制即將沿命令管線傳遞哪些物件。</maml:para>
</maml:description>
<maml:copyright>
<maml:para></maml:para>
</maml:copyright>
<command:verb>Where</command:verb>
<command:noun>Object</command:noun>
<dev:version></dev:version>
</command:details>
<maml:description>
<maml:para>Where-Object Cmdlet 會從傳遞給它的一組物件中選取物件。它會使用指令碼區塊當做篩選器並評估每個物件的指令碼區塊。如果評估的結果是 True,就會傳回此物件。如果評估的結果不是 True,就會忽略此物件。</maml:para>
</maml:description>
<!-- Cmdlet syntax section-->
<command:syntax>
<command:syntaxItem>
<maml:name>Where-Object</maml:name>
<command:parameter required="true" variableLength="false" globbing="false" pipelineInput="false" position="1">
<maml:name>FilterScript</maml:name>
<maml:description>
<maml:para>指定用來篩選物件的指令碼區塊。請以大括號 ( {} ) 括住指令碼區塊。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">scriptblock</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="true (ByValue)" position="named">
<maml:name>InputObject</maml:name>
<maml:description>
<maml:para>指定要篩選的物件。您也可經由管道將物件輸出至 Where-Object。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">psobject</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>FilterScript</maml:name>
<maml:description>
<maml:para>指定用來篩選物件的指令碼區塊。請以大括號 ( {} ) 括住指令碼區塊。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">scriptblock</command:parameterValue>
<dev:type>
<maml:name>scriptblock</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue></dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="true (ByValue)" position="named">
<maml:name>InputObject</maml:name>
<maml:description>
<maml:para>指定要篩選的物件。您也可經由管道將物件輸出至 Where-Object。</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">psobject</command:parameterValue>
<dev:type>
<maml:name>psobject</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.Management.Automation.PSObject</maml:name>
<maml:uri />
<maml:description />
</dev:type>
<maml:description>
<maml:para>
<!-- description -->
您可經由管道將要篩選的物件輸出至 Where-Object。
</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 -->
</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>
get-service | where-object {$_.Status -eq "Stopped"} </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個命令會取得目前已停止的所有服務清單。"$" 符號代表傳遞給 Where-Object 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>
-------------------------- 範例 2 --------------------------
</maml:title>
<maml:introduction>
<maml:para>C:\PS></maml:para>
</maml:introduction>
<dev:code>
get-process | where-object {$_.workingset -gt 25000*1024} </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個命令會列出工作組超過 25,000 KB 的處理序。因為 WorkingSet 屬性值是以位元組做為儲存單位,所以 25,000 值要乘以 1,024。</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-process | where-object { $_.ProcessName -match "^p.*" } </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個命令會取得具有以字母 "p" 為開頭之 ProcessName 屬性的處理序。比對運算子可讓您在 Where 子句中使用規則運算式。</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-process -name svchost | where-object {$True} </dev:code>
<dev:remarks>
<maml:para>描述</maml:para>
<maml:para>-----------</maml:para>
<maml:para>這個命令會列出名為 "svchost" 的所有處理序。
Where-Object Cmdlet 會評估指令碼區塊 (通常包含目前在管線 ($_) 中之物件的參考),並將結果轉換為布林值型別:Ture 或 False。如果結果是 True,就會傳回此物件。否則,就會捨棄此物件。
在這個範例中,指令碼區塊傳回的正是 True,因此系統將傳回所有物件。</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=113423</maml:uri>
</maml:navigationLink>
</maml:relatedLinks>
</command:command>
<!-- v 1.1.0.9 -->
<providerHelp>
<Name>
Alias
</Name>
<Drives>
<Para>Alias:</Para>
</Drives>
<Synopsis>
提供對 Windows PowerShell 別名及其代表值的存取權。
</Synopsis>
<DetailedDescription>
<para>Windows PowerShell Alias 提供者可以用來取得、新增、變更、清除和刪除 Windows PowerShell 中的別名。
別名是指 Cmdlet、函數或可執行檔的交替名稱。Windows PowerShell 包含一組內建的別名。而且,您可以將自己的別名新增至目前的工作階段和 Windows PowerShell 設定檔。
Alias 提供者是指僅包含別名物件的一般命名空間。別名沒有子項目。
每個別名都是 System.Management.Automation.AliasInfo 類別的執行個體。
Alias 提供者會在 Alias: 磁碟機中公開其資料存放區。若要使用別名,您可以使用下列命令,將目前的位置變更為 Alias: 磁碟機:
set-location alias:
或者,您也可以從任何其他 Windows PowerShell 磁碟機執行工作。若要從其他位置參考別名,請在路徑中使用磁碟機名稱 Alias:。
Windows PowerShell 包括了一組設計用來檢視和變更別名的 Cmdlet:
Export-Alias
Get-Alias
Import-Alias
New-Alias
Set-Alias
使用這些 Cmdlet 時,並不需要在名稱中指定 Alias: 磁碟機。
Alias 提供者支援具有 Item 名詞的所有 Cmdlet,但 Invoke-Item Cmdlet 除外。此外,它也支援 Get-Content 和 Set-Content Cmdlet。Alias 提供者不支援具有 ItemProperty 名詞的 Cmdlet。而且,Alias 提供者不支援任何 Cmdlet 中的 Filter 參數。
別名的所有變更都只會影響目前的工作階段。若要儲存這些變更,請將變更新增至 Windows PowerShell 設定檔。或者,請使用 Export-Alias 和 Import-Alias Cmdlet。</para>
</DetailedDescription>
<Capabilities>
<para></para>
</Capabilities>
<Filters>
<para></para>
</Filters>
<Notes>
</Notes>
<Tasks>
<Task>
<Title>
切換到 Alias: 磁碟機
</Title>
<Description>
<para></para>
</Description>
<Examples>
<Example>
<Title>
-------------------------- 範例 1 --------------------------
</Title>
<Introduction>
<para>這個命令會將目前位置切換到 Alias: 磁碟機。您可以在 Windows PowerShell 中從任何的磁碟機執行此命令。若要返回檔案系統磁碟機,請輸入磁碟機名稱。例如,請輸入 "set-location c:"。</para>
</Introduction>
<Code>
set-location alias:
</Code>
<Remarks>
<para></para>
</Remarks>
</Example>
</Examples>
</Task>
<Task>
<Title>
取得別名
</Title>
<Description>
<para></para>
</Description>
<Examples>
<Example>
<Title>
-------------------------- 範例 1 --------------------------
</Title>
<Introduction>
<para>這個命令會取得目前工作階段中所有別名的清單。您可以在任何的 Windows PowerShell 磁碟機上執行此命令。</para>
</Introduction>
<Code>
get-item -path alias:
</Code>
<Remarks>
<para></para>
</Remarks>
</Example>
<Example>
<Title>
-------------------------- 範例 2 --------------------------
</Title>
<Introduction>
<para>這個命令會取得 "ls" 別名。因為它包含路徑,所以您可以在任何 Windows PowerShell 磁碟機中使用它。</para>
</Introduction>
<Code>
get-item -path alias:ls
</Code>
<Remarks>
<para>如果您的位置是在 Alias: 磁碟機,就可以在路徑中省略磁碟機名稱。</para>
</Remarks>
</Example>
<Example>
<Title>
-------------------------- 範例 3 --------------------------
</Title>
<Introduction>
<para>這個命令會取得與 Get-ChildItem Cmdlet 相關聯的別名清單。它會使用用來儲存 Cmdlet 名稱的 Definition 屬性。</para>
</Introduction>
<Code>
get-item -path alias:* | where-object {$_.Definition -eq "Get-Childitem"}
</Code>
<Remarks>
<para>當有別名的項目是可執行檔時,Definition 就會包含該檔案的完整路徑。</para>
</Remarks>
</Example>
<Example>
<Title>
-------------------------- 範例 4 --------------------------
</Title>
<Introduction>
<para>這個命令會取得目前位置為 Alias: 磁碟機時所有別名的清單。它會使用萬用字元 (*) 來指出目前位置的所有內容。</para>
</Introduction>
<Code>
get-item -path *
</Code>
<Remarks>
<para>在 Alias: 磁碟機中的點 (.) 代表目前的位置,而萬用字元 (*) 代表目前位置中的所有項目,這兩種表示方式會產生相同作用。例如,"get-item -path ." 或 "get-item *" 會產生相同的結果。</para>
</Remarks>
</Example>
</Examples>
</Task>
<Task>
<Title>
建立新別名
</Title>
<Description>
<para></para>
</Description>
<Examples>
<Example>
<Title>
-------------------------- 範例 1 --------------------------
</Title>
<Introduction>
<para>這個命令會為 Get-Service Cmdlet 建立別名 "serv"。因為目前的位置是 Alias: 磁碟機,所以 Path 參數的值是點 (.)。該點代表目前位置。
這個命令也會使用 Options 動態參數設定別名上的 AllScope 和 Constant 選項。只有當您位於 Alias: 磁碟機時,才能在 New-Item Cmdlet 中使用 Options 參數。</para>
</Introduction>
<Code>
new-item -path . -name serv -value Get-Service -Options "AllScope,Constant"
</Code>
<Remarks>
<para>如果您的位置是在 Alias: 磁碟機,就可以在路徑中省略磁碟機名稱。</para>
</Remarks>
</Example>
<Example>
<Title>
-------------------------- 範例 2 --------------------------
</Title>
<Introduction>
<para>您可以為任何呼叫命令的項目建立別名。這個命令會為 Notepad.exe 建立別名 "np"。</para>
</Introduction>
<Code>
new-item -path alias:np -value c:\windows\notepad.exe
</Code>
<Remarks>
<para></para>
</Remarks>
</Example>
<Example>
<Title>
-------------------------- 範例 3 --------------------------
</Title>
<Introduction>
<para>您可以為任何函數建立別名。您可以使用這項功能,建立同時包含 Cmdlet 及其參數的別名。
第一個命令會建立 CD32 函數,此函數會將目前目錄變更為 System32 目錄。第二個命令會為 CD32 函數建立別名 "go"。分號 (;) 是命令分隔符號。
當此命令執行完成時,您就可以使用 "CD32" 或 "go" 來叫用此函數。</para>
</Introduction>
<Code>
function CD32 {set-location -path c:\windows\system32} set-item -path alias:go -value CD32
</Code>
<Remarks>
<para></para>
</Remarks>
</Example>
</Examples>
</Task>
<Task>
<Title>
顯示別名的屬性和方法
</Title>
<Description>
<para></para>
</Description>
<Examples>
<Example>
<Title>
-------------------------- 範例 1 --------------------------
</Title>
<Introduction>
<para>這個命令會使用 Get-Item Cmdlet 來取得所有別名。管線運算子 (|) 會將結果傳送至 Get-Member Cmdlet,再由後者顯示物件的方法和屬性。</para>
</Introduction>
<Code>
get-item -path alias:* | get-member
</Code>
<Remarks>
<para>當您經由管道將物件的集合 (例如 Alias: 磁碟機中的別名集合) 輸出至 Get-Member 時,Get-Member 就會個別評估集合中的每個物件。然後,Get-Member 會傳回它所找到之每種物件類型的相關資訊。如果所有物件都屬於同一類型,則傳回單一物件類型的相關資訊。在這個範例中,所有別名都是 AliasInfo 物件。
若要取得 AliasInfo 物件集合的相關資訊,請使用 Get-Member 的 InputObject 參數。例如,請使用下列命令:
Get-Member -InputObject (Get-Item alias:*)
當您使用 InputObject 時,Get-Member 就會評估集合,而非評估集合中的物件。</para>
</Remarks>
</Example>
<Example>
<Title>
-------------------------- 範例 2 --------------------------
</Title>
<Introduction>
<para>這個命令會列出 "dir" 別名的屬性值。它會使用 Get-Item Cmdlet 來取得代表 "dir" 別名的物件。管線運算子 (|) 會將結果傳送至 Format-List 命令。Format-List 命令會使用 Property 參數搭配萬用字元 (*) 來格式化並顯示所有 "dir" 別名屬性的值。</para>
</Introduction>
<Code>
get-item alias:dir | format-list -property *
</Code>
<Remarks>
<para></para>
</Remarks>
</Example>
</Examples>
</Task>
<Task>
<Title>
變更別名的屬性
</Title>
<Description>
<para></para>
</Description>
<Examples>
<Example>
<Title>
-------------------------- 範例 1 --------------------------
</Title>
<Introduction>
<para>您可以使用 Set-Item Cmdlet 搭配 Options 動態參數來變更別名的 Options 屬性值。
這個命令會為 "dir" 別名設定 AllScope 和 ReadOnly 選項。此命令會使用 Set-Item Cmdlet 的 Options 動態參數。只有當您搭配 Alias 或 Function 提供者使用 Set-Item 時,才可以在其中使用 Options 參數。</para>
</Introduction>
<Code>
set-item -path alias:dir -options "AllScope,ReadOnly"
</Code>
<Remarks>
<para></para>
</Remarks>
</Example>
<Example>
<Title>
-------------------------- 範例 2 --------------------------
</Title>
<Introduction>
<para>這個命令會使用 Set-Item Cmdlet 來變更 "gp" 別名,讓它代表 Get-Process Cmdlet 而非 Get-ItemProperty Cmdlet。因為 "gp" 別名的 Options 屬性值設定為 ReadOnly,所以 Force 參數為必要項。此外,因為這個命令是從 Alias: 磁碟機內部所提交,所以路徑中並未指定磁碟機。</para>
</Introduction>
<Code>
set-item -path gp -value get-process -force
</Code>
<Remarks>
<para>這項變更會影響到 4 個定義此別名和命令之間關聯性的屬性。若要檢視變更的影響,請輸入下列命令:
get-item -path gp | format-list -property *</para>
</Remarks>
</Example>
<Example>
<Title>
-------------------------- 範例 3 --------------------------
</Title>
<Introduction>
<para>這個命令會使用 Rename-Item Cmdlet,將 "popd" 別名變更為 "pop"。</para>
</Introduction>
<Code>
rename-item -path alias:popd -newname pop
</Code>
<Remarks>
<para></para>
</Remarks>
</Example>
</Examples>
</Task>
<Task>
<Title>
複製別名
</Title>
<Description>
<para></para>
</Description>
<Examples>
<Example>
<Title>
-------------------------- 範例 1 --------------------------
</Title>
<Introduction>
<para>這個命令會複製 pushd 別名,以便針對 Push-Location Cmdlet 建立新的 push 別名。</para>
</Introduction>
<Code>
copy-item -path alias:pushd -destination alias:push
</Code>
<Remarks>
<para>建立新的別名時,其 Description 屬性具有 Null 值。而且,其 Option 屬性具有 None 值。
如果此命令是從 Alias: 磁碟機內部所提交,您就可以在 Path 參數值中省略磁碟機名稱。</para>
</Remarks>
</Example>
</Examples>
</Task>
<Task>
<Title>
刪除別名
</Title>
<Description>
<para></para>
</Description>
<Examples>
<Example>
<Title>
-------------------------- 範例 1 --------------------------
</Title>
<Introduction>
<para>這個命令會從目前的工作階段中刪除 serv 別名。您可以在任何的 Windows PowerShell 磁碟機上執行此命令。</para>
</Introduction>
<Code>
remove-item -path alias:serv
</Code>
<Remarks>
<para>如果您的位置是在 Alias: 磁碟機,就可以在路徑中省略磁碟機名稱。</para>
</Remarks>
</Example>
<Example>
<Title>
-------------------------- 範例 2 --------------------------
</Title>
<Introduction>
<para>這個命令會刪除開頭為 "s" 的別名。它不會刪除唯讀的別名。</para>
</Introduction>
<Code>
clear-item -path alias:s*
</Code>
<Remarks>
<para></para>
</Remarks>
</Example>
<Example>
<Title>
-------------------------- 範例 3 --------------------------
</Title>
<Introduction>
<para>這個命令會從目前的工作階段中刪除所有別名,但是 Options 屬性值為 Constant 的別名除外。如果沒有使用 Force 參數,此命令就不會刪除 Options 屬性值為 ReadOnly 的別名。</para>
</Introduction>
<Code>
remove-item alias:* -force
</Code>
<Remarks>
<para></para>
</Remarks>
</Example>
</Examples>
</Task>
</Tasks>
<DynamicParameters>
<DynamicParameter>
<Name>Options</Name>
<CmdletSupported>New-Item, Set-Item</CmdletSupported>
<Type>
<Name>System.Management.Automation.ScopedItemOptions</Name>
</Type>
<Description>決定別名的 Options 屬性值。</Description>
<PossibleValues>
<PossibleValue>
<Value>無</Value>
<Description>
<para>沒有選項。此值為預設值。</para>
</Description>
</PossibleValue>
<PossibleValue>
<Value>Constant</Value>
<Description>
<para>無法刪除別名,且無法變更別名的屬性。只有建立別名時才能使用 Constant。既有的別名無法將選項變更為 Constant。</para>
</Description>
</PossibleValue>
<PossibleValue>
<Value>Private</Value>
<Description>
<para>別名只會顯示於目前範圍 (不會顯示於子範圍)。</para>
</Description>
</PossibleValue>
<PossibleValue>
<Value>ReadOnly</Value>
<Description>
<para>您無法變更別名的屬性,除非使用 Force 參數。您可以使用 Remove-Item 刪除別名。</para>
</Description>
</PossibleValue>
<PossibleValue>
<Value>AllScope</Value>
<Description>
<para>將別名複製到所有新建立的範圍。</para>
</Description>
</PossibleValue>
</PossibleValues>
</DynamicParameter>
</DynamicParameters>
<RelatedLinks>
<navigationLink>
<linkText>about_Aliases</linkText>
<uri />
</navigationLink>
<navigationLink>
<linkText>about_Providers</linkText>
<uri />
</navigationLink>
</RelatedLinks>
</providerHelp>
<!-- v 1.1.0.9 -->
<providerHelp>
<Name>
Environment
</Name>
<Drives>
<Para>Env:</Para>
</Drives>
<Synopsis>
提供 Windows 環境變數的存取權。
</Synopsis>
<DetailedDescription>
<para>Windows PowerShell Environment 提供者可以用來取得、新增、變更、清除和刪除 Windows PowerShell 中的 Windows 環境變數。
Environment 提供者是指僅包含代表環境變數之物件一般命名空間。變數沒有子項目。
每個環境變數都是 System.Collections.DictionaryEntry 類別的執行個體。變數的名稱就是字典索引鍵。環境變數的值就是字典值。
Environment 提供者會在 Env: 磁碟機中公開其資料存放區。若要使用環境變數,請將您的位置變更為 Env: 磁碟機 ("set-location env:"),或是從其他 Windows PowerShell 磁碟機執行工作。若要從其他位置參考環境變數,請在路徑中使用磁碟機名稱 Env:。
環境變數提供者支援包含 Item 名詞的所有 Cmdlet,但 Invoke-Item 除外。此外,它也支援 Get-Content 和 Set-Content Cmdlet。不過,它既不支援包含 ItemProperty 名詞的 Cmdlet,也不支援任何 Cmdlet 中的 Filter 參數。
環境變數必須符合一般的命名標準。此外,名稱中不能包括等號 (=)。
環境變數的變更只會影響目前的工作階段。若要儲存變更,請將變更新增到 Windows PowerShell 設定檔,或是使用 Export-Console 來儲存目前的工作階段。</para>
</DetailedDescription>
<Capabilities>
<para></para>
</Capabilities>
<Filters>
<para></para>
</Filters>
<Notes>
Environment 提供者不支援任何動態參數。
</Notes>
<Tasks>
<Task>
<Title>
切換到 Env: 磁碟機
</Title>
<Description>
<para></para>
</Description>
<Examples>
<Example>
<Title>
-------------------------- 範例 1 --------------------------
</Title>
<Introduction>
<para>這個命令會將目前的位置變更為 Env: 磁碟機:</para>
</Introduction>
<Code>
set-location env:
</Code>
<Remarks>
<para>您可以在 Windows PowerShell 中從任何的磁碟機執行此命令。若要返回檔案系統磁碟機,請輸入磁碟機名稱。例如,輸入:
set-location c:</para>
</Remarks>
</Example>
</Examples>
</Task>
<Task>
<Title>
取得環境變數
</Title>
<Description>
<para></para>
</Description>
<Examples>
<Example>
<Title>
-------------------------- 範例 1 --------------------------
</Title>
<Introduction>
<para>這個命令會列出目前工作階段中的所有環境變數:</para>
</Introduction>
<Code>
get-childitem -path env:
</Code>
<Remarks>
<para>您可以從任何的 Windows PowerShell 磁碟機執行此命令。</para>
</Remarks>
</Example>
<Example>
<Title>
-------------------------- 範例 2 --------------------------
</Title>
<Introduction>
<para>這個命令會取得 WINDIR 環境變數:</para>
</Introduction>
<Code>
get-childitem -path env:windir
</Code>
<Remarks>
<para></para>
</Remarks>
</Example>
<Example>
<Title>
-------------------------- 範例 3 --------------------------
</Title>
<Introduction>
<para>這個命令會取得目前工作階段中所有環境變數的清單,然後依照名稱進行排序:</para>
</Introduction>
<Code>
get-childitem | sort-object -property name
</Code>
<Remarks>
<para>依據預設,環境變數會依 Windows PowerShell 找到它們時的順序顯示。這個命令是在 Env: 磁碟機中提交。
當您從其他磁碟機執行這個命令時,請新增值為 Env: 的 Path 參數。</para>
</Remarks>
</Example>
</Examples>
</Task>
<Task>
<Title>
建立新的環境變數
</Title>
<Description>
<para></para>
</Description>
<Examples>
<Example>
<Title>
-------------------------- 範例 1 --------------------------
</Title>
<Introduction>
<para>這個命令會建立值為 Non-Admin 的 USERMODE 環境變數:</para>
</Introduction>
<Code>
new-item -path . -name USERMODE -value Non-Admin
</Code>
<Remarks>
<para>因為目前的位置是 Env: 磁碟機,所以 Path 參數的值是點 (.)。該點代表目前位置。
如果目前的位置不是 Env: 磁碟機,Path 參數值就會是 Env:。</para>
</Remarks>
</Example>
</Examples>
</Task>
<Task>
<Title>
顯示環境變數的屬性和方法
</Title>
<Description>
<para></para>
</Description>
<Examples>
<Example>
<Title>
-------------------------- 範例 1 --------------------------
</Title>
<Introduction>
<para>這個命令會使用 Get-ChildItem Cmdlet 來取得所有環境變數:</para>
</Introduction>
<Code>
get-childitem -path env: | get-member
</Code>
<Remarks>
<para>管線運算子 (|) 會將結果傳送至 Get-Member,再由後者顯示物件的方法和屬性。
當您經由管道將物件的集合 (例如 Env: 磁碟機中的環境變數集合) 輸出至 Get-Member 時,Get-Member 就會個別評估集合中的每個物件。然後,Get-Member 會傳回它所找到之每種物件類型的相關資訊。如果所有物件都屬於同一類型,則傳回單一物件類型的相關資訊。在這個範例中,所有的環境變數都是 DictionaryEntry 物件。
若要取得 DictionaryEntry 物件集合的相關資訊,請使用 Get-Member 的 InputObject 參數。例如,輸入:
get-member -inputobject (get-childitem env:)
當您使用 InputObject 參數時,Get-Member 就會評估集合,而非評估集合中的物件。</para>
</Remarks>
</Example>
<Example>
<Title>
-------------------------- 範例 2 --------------------------
</Title>
<Introduction>
<para>這個命令會列出 WINDIR 環境變數的屬性值:</para>
</Introduction>
<Code>
get-item env:windir | format-list -property *
</Code>
<Remarks>
<para>它會使用 Get-Item Cmdlet 來取得代表 WINDIR 環境變數的物件。管線運算子 (|) 會將結果傳送至 Format-List 命令。該命令會使用 Property 參數搭配萬用字元 (*) 來格式化並顯示 WINDIR 環境變數的所有屬性值。</para>
</Remarks>
</Example>
</Examples>
</Task>
<Task>
<Title>
變更環境變數的屬性
</Title>
<Description>
<para></para>
</Description>
<Examples>
<Example>
<Title>
-------------------------- 範例 1 --------------------------
</Title>
<Introduction>
<para>這個命令會使用 Rename-Item Cmdlet,將您所建立的 USERMODE 環境變數名稱變更為 USERROLE:</para>
</Introduction>
<Code>
rename-item -path env:USERMODE -newname USERROLE
</Code>
<Remarks>
<para>這項變更會影響到 DictionaryEntry 物件的 Name、Key 和 PSPath 等屬性。
請勿變更系統所使用的環境變數名稱。雖然這些變更只會影響目前的工作階段,但是它們可能會造成系統或程式執行錯誤。</para>
</Remarks>
</Example>
<Example>
<Title>
-------------------------- 範例 2 --------------------------
</Title>
<Introduction>
<para>這個命令會使用 Set-Item Cmdlet,將 USERROLE 環境變數的值變更為 Administrator:</para>
</Introduction>
<Code>
set-item -path env:USERROLE -value Administrator
</Code>
<Remarks>
<para></para>
</Remarks>
</Example>
</Examples>
</Task>
<Task>
<Title>
複製環境變數
</Title>
<Description>
<para></para>
</Description>
<Examples>
<Example>
<Title>
-------------------------- 範例 1 --------------------------
</Title>
<Introduction>
<para>這個命令會將 USERROLE 環境變數的值複製到 USERROLE2 環境變數:</para>
</Introduction>
<Code>
copy-item -path env:USERROLE -destination env:USERROLE2
</Code>
<Remarks>
<para></para>
</Remarks>
</Example>
</Examples>
</Task>
<Task>
<Title>
刪除環境變數
</Title>
<Description>
<para></para>
</Description>
<Examples>
<Example>
<Title>
-------------------------- 範例 1 --------------------------
</Title>
<Introduction>
<para>這個命令會從目前的工作階段中刪除 USERROLE2 環境變數:</para>
</Introduction>
<Code>
remove-item -path env:USERROLE2
</Code>
<Remarks>
<para>您可以在任何的 Windows PowerShell 磁碟機上執行此命令。如果您的位置是在 Env: 磁碟機上,就可以在路徑中省略磁碟機名稱。</para>
</Remarks>
</Example>
<Example>
<Title>
-------------------------- 範例 2 --------------------------
</Title>
<Introduction>
<para>這個命令會刪除 USERROLE 環境變數。</para>
</Introduction>
<Code>
clear-item -path env:USERROLE
</Code>
<Remarks>
<para></para>
</Remarks>
</Example>
</Examples>
</Task>
</Tasks>
<DynamicParameters>
</DynamicParameters>
<RelatedLinks>
<navigationLink>
<linkText>about_Providers</linkText>
<uri />
</navigationLink>
</RelatedLinks>
</providerHelp>
<!-- v 1.1.0.9 -->
<providerHelp>
<Name>
FileSystem
</Name>
<Drives>
<Para>C、D</Para>
</Drives>
<Synopsis>
提供檔案和目錄的存取權。
</Synopsis>
<DetailedDescription>
<para>Windows PowerShell FileSystem 提供者可以用來取得、新增、變更、清除和刪除 Windows PowerShell 中的檔案和目錄。
FileSystem 提供者會公開對應到您電腦上所設定之邏輯磁碟機的 Windows PowerShell 磁碟機,其中包括已對應到網路共用的磁碟機。例如,裝有一台軟碟機、一台硬碟機和一個對應的網路共用目錄的電腦,其磁碟機名稱可能會顯示 A、C 和 Z。FileSystem 提供者會公開直接對應到 A、C 和 Z 的 Windows PowerShell 磁碟機,讓您能夠從 Windows PowerShell 內部參考這些磁碟機。例如,您可以使用 C: 來參照磁碟機 C,如下列範例所示:
get-childitem c:
這個命令會傳回 C 磁碟機上的所有內容,包括檔案和目錄。當您透過 FileSystem 提供者參考特定目錄或檔案時,必須提供可識別該目錄或檔案的必要資訊。這表示在某些情況下,您必須提供完整格式名稱。完整格式名稱包括了磁碟機名稱 (加上冒號)、任何目錄和子目錄名稱,以及檔案名稱 (如果適用的話)。例如,下列範例會顯示 Shell.dll 檔案的完整格式名稱,此檔案是位在 C 磁碟機上 Windows 目錄的 System32 子目錄中:
c:\windows\system32\shell.dll
您可以發現到,完整格式名稱的每個元素都是以反斜線 (\) 分隔。Windows PowerShell 也允許您使用斜線 (/),以便與各種其他殼層維持一致性。
在某些情況下,您並不需要在參照檔案或目錄時提供完整格式名稱。例如,如果您想要存取目前工作位置中的檔案,則只需要提供該檔案名稱即可。如果目前工作位置是 c:\windows,您就可以使用下列命令來檢視位在該目錄中的所有 .dll 檔案清單:
get-childitem *.dll
如果工作目錄不是 c:\windows,而是類似 c:\program files\Windows PowerShell 的其他位置,您的命令就需要包含完整格式名稱:
get-childitem c:\windows\*.dll
在某些情況下,您可以使用相對的位置參照。如果工作位置是 c:\windows,而您想要檢視 c:\windows\system32 目錄中的 .dll 檔案清單,則可以使用下列命令:
get-childitem .\system32\*.dll
在 \system32 前面的句號代表目前的工作位置。
在某些情況下,目前的工作位置會是在其他磁碟機上,而不是在 FileSystem 磁碟機上。如果遇到這種情況,您一律必須在參照中包含目標磁碟機的名稱。例如,假設目前的工作位置是 env: 磁碟機。若要檢視 C 磁碟機的內容,您可以使用下列命令:
get-childitem c:</para>
</DetailedDescription>
<Capabilities>
<para></para>
</Capabilities>
<Filters>
<para></para>
</Filters>
<Notes>
</Notes>
<Tasks>
<Task>
<Title>
瀏覽檔案系統
</Title>
<Description>
<para></para>
</Description>
<Examples>
<Example>
<Title>
-------------------------- 範例 1 --------------------------
</Title>
<Introduction>
<para>這個命令會取得目前的位置:</para>
</Introduction>
<Code>
get-location
</Code>
<Remarks>
<para>Get-Location Cmdlet 所包含的命令功能類似於 Windows 命令提示字元中的 cd 命令以及 UNIX 中的 pwd 命令。如需詳細資訊,請輸入:
get-help get-location</para>
</Remarks>
</Example>
<Example>
<Title>
-------------------------- 範例 2 --------------------------
</Title>
<Introduction>
<para>這個命令會設定目前的位置:</para>
</Introduction>
<Code>
set-location C:
</Code>
<Remarks>
<para></para>
</Remarks>
</Example>
</Examples>
</Task>
<Task>
<Title>
取得檔案和目錄資訊
</Title>
<Description>
<para></para>
</Description>
<Examples>
<Example>
<Title>
-------------------------- 範例 1 --------------------------
</Title>
<Introduction>
<para>這個命令會取得目前目錄中的所有檔案和目錄:</para>
</Introduction>
<Code>
get-childitem
</Code>
<Remarks>
<para>根據預設,Get-ChildItem Cmdlet 不會遞迴執行。當您執行這個命令時,如果目前的目錄存在檔案和資料夾,系統就會傳回 System.IO.FileInfo 物件和 System.IO.DirectoryInfo 物件。</para>
</Remarks>
</Example>
<Example>
<Title>
-------------------------- 範例 2 --------------------------
</Title>
<Introduction>
<para>這個命令會使用 Get-ChildItem 來取得目前目錄中的所有檔案和目錄:</para>
</Introduction>
<Code>
get-childitem | where-object {!$_.psiscontainer}
</Code>
<Remarks>
<para>它會經由管道將結果輸出至 Where-Object,由後者檢查 PSIsContainer 屬性,並且只讓不是 (!) 容器的物件通過管線。</para>
</Remarks>
</Example>
<Example>
<Title>
-------------------------- 範例 3 --------------------------
</Title>
<Introduction>
<para>這個命令會使用 Get-ChildItem 來取得目前目錄中的所有檔案和目錄。它會經由管道將結果輸出至 Where-Object,由後者檢查 PSIsContainer 屬性,並且只讓屬於容器的物件通過管線。</para>
</Introduction>
<Code>
get-childitem | where-object {$_.psiscontainer}
</Code>
<Remarks>
<para></para>
</Remarks>
</Example>
<Example>
<Title>
-------------------------- 範例 4 --------------------------
</Title>
<Introduction>
<para>這個命令會使用 Get-ChildItem 來取得目前目錄中的所有檔案和目錄:</para>
</Introduction>
<Code>
get-item -path a | format-list *
</Code>
<Remarks>
<para>它會經由管道將結果輸出至 Where-Object Cmdlet,由後者檢查 PSIsContainer 屬性,並且只讓屬於容器的物件通過管線。</para>
</Remarks>
</Example>
<Example>
<Title>
-------------------------- 範例 5 --------------------------
</Title>
<Introduction>
<para>這個命令會使用 Get-Item Cmdlet 來取得 Test.txt 檔案的相關資訊:</para>
</Introduction>
<Code>
get-item -path test.txt | format-list *
</Code>
<Remarks>
<para>Format-List Cmdlet 是用於顯示產生之物件的所有屬性。</para>
</Remarks>
</Example>
</Examples>
</Task>
<Task>
<Title>
複製檔案和目錄
</Title>
<Description>
<para></para>
</Description>
<Examples>
<Example>
<Title>
-------------------------- 範例 1 --------------------------
</Title>
<Introduction>
<para>這個命令會將 A.txt 檔案從 C:\A 目錄複製到 C:\A\Bb 目錄:</para>
</Introduction>
<Code>
copy-item -path C:\a\a.txt -destination C:\a\bb\a.txt
</Code>
<Remarks>
<para>它會在不先提示確認的情況下,覆寫目的地目錄中的檔案。</para>
</Remarks>
</Example>
<Example>
<Title>
-------------------------- 範例 2 --------------------------
</Title>
<Introduction>
<para>這個命令會將 C:\A\Bb 目錄中所有副檔名為 .txt 的檔案複製到 C:\A\Cc\Ccc\ 目錄:</para>
</Introduction>
<Code>
copy-item -path C:\a\bb\*.txt -destination C:\a\cc\ccc\
</Code>
<Remarks>
<para>它會使用檔案的原始名稱。這個命令會在不先提示確認的情況下,覆寫目的地目錄中現有的檔案。</para>
</Remarks>
</Example>
<Example>
<Title>
-------------------------- 範例 3 --------------------------
</Title>
<Introduction>
<para>將 C:\a 目錄中的所有目錄和檔案複製到 C:\c 目錄。除非指定 Force 參數,否則當目的地目錄中已存在任何一個要複製的目錄時,此命令將會失敗。</para>
</Introduction>
<Code>
copy-item -path C:\a\* -destination C:\c -recurse
</Code>
<Remarks>
<para></para>
</Remarks>
</Example>
</Examples>
</Task>
<Task>
<Title>
移動檔案和目錄
</Title>
<Description>
<para></para>
</Description>
<Examples>
<Example>
<Title>
-------------------------- 範例 1 --------------------------
</Title>
<Introduction>
<para>這個命令會將 C:\A 目錄中的 C.txt 檔案移動到 C:\A\Aa 目錄:</para>
</Introduction>
<Code>
move-item -path C:\a\c.txt -destination C:\a\aa
</Code>
<Remarks>
<para>這個命令不會自動覆寫具有相同名稱的現有檔案。若要強制此 Cmdlet 覆寫現有的檔案,請指定 Force 參數。</para>
</Remarks>
</Example>
<Example>
<Title>
-------------------------- 範例 2 --------------------------
</Title>
<Introduction>
<para>這個命令會將 C:\A 目錄及其所有內容移動到 C:\B 目錄:</para>
</Introduction>
<Code>
move-item -path C:\a -destination C:\b
</Code>
<Remarks>
<para>如果您所要移動的目錄就是目前的位置,則無法移動該目錄。</para>
</Remarks>
</Example>
</Examples>
</Task>
<Task>
<Title>
管理檔案內容
</Title>
<Description>
<para></para>
</Description>
<Examples>
<Example>
<Title>
-------------------------- 範例 1 --------------------------
</Title>
<Introduction>
<para>這個命令會將 "test content" 字串附加到 Test.txt 檔案:</para>
</Introduction>
<Code>
add-content -path test.txt -value "test content"
</Code>
<Remarks>
<para>在 Test.txt 檔案中的現有內容並不會被刪除。</para>
</Remarks>
</Example>
<Example>
<Title>
-------------------------- 範例 2 --------------------------
</Title>
<Introduction>
<para>這個命令會取得 Test.txt 檔案的內容,並將內容顯示在主控台中:</para>
</Introduction>
<Code>
get-content -path test.txt
</Code>
<Remarks>
<para>您可以經由管道將檔案的內容輸出至其他 Cmdlet。例如,下列命令會讀取 Test.txt 檔案的內容,然後提供它們做為 ConvertTo-HTML Cmdlet 的輸入:
get-content -path test.txt |convertto-html</para>
</Remarks>
</Example>
<Example>
<Title>
-------------------------- 範例 3 --------------------------
</Title>
<Introduction>
<para>這個命令會將 Test.txt 檔案的內容取代成 "test content" 字串:</para>
</Introduction>
<Code>
set-content -path test.txt -value "test content"
</Code>
<Remarks>
<para>它會覆寫 Test.txt 的內容。您可以在建立檔案時,使用 New-Item Cmdlet 的 Value 參數為該檔案新增內容。</para>
</Remarks>
</Example>
</Examples>
</Task>
<Task>
<Title>
管理安全性描述元
</Title>
<Description>
<para></para>
</Description>
<Examples>
<Example>
<Title>
-------------------------- 範例 1 --------------------------
</Title>
<Introduction>
<para>這個命令會傳回 System.Security.AccessControl.FileSecurity 物件:</para>
</Introduction>
<Code>
get-acl -path test.txt | format-list -property *
</Code>
<Remarks>
<para>如需這個物件的詳細資訊,請經由管道將此命令輸出至 Get-Member Cmdlet。或者,請參閱 MSDN (Microsoft Developer Network) Library 中的<FileSecurity 類別>,網址為:http://go.microsoft.com/fwlink/?LinkId=145718。</para>
</Remarks>
</Example>
<Example>
<Title>
-------------------------- 範例 2 --------------------------
</Title>
<Introduction>
<para>這個命令會傳回 System.Security.AccessControl.DirectorySecurity 物件:</para>
</Introduction>
<Code>
get-acl -path test_directory | format-list -property *
</Code>
<Remarks>
<para>如需這個物件的詳細資訊,請經由管道將此命令輸出至 Get-Member Cmdlet。或者,請參閱 MSDN (Microsoft Developer Network) Library 中的<DirectorySecurity 類別>,網址為:http://go.microsoft.com/fwlink/?LinkId=145736。</para>
</Remarks>
</Example>
</Examples>
</Task>
<Task>
<Title>
建立檔案和目錄
</Title>
<Description>
<para></para>
</Description>
<Examples>
<Example>
<Title>
-------------------------- 範例 1 --------------------------
</Title>
<Introduction>
<para>這個命令會在 C 磁碟機上建立 Logfiles 目錄:</para>
</Introduction>
<Code>
new-item -path c:\ -name logfiles -type directory
</Code>
<Remarks>
<para></para>
</Remarks>
</Example>
<Example>
<Title>
-------------------------- 範例 2 --------------------------
</Title>
<Introduction>
<para>這個命令會在 C:\Logfiles 目錄中建立 Log2.txt 檔案,然後將 "test log" 字串新增到此檔案:</para>
</Introduction>
<Code>
new-item -path c:\logfiles -name log.txt -type file
</Code>
<Remarks>
<para></para>
</Remarks>
</Example>
<Example>
<Title>
-------------------------- 範例 3 --------------------------
</Title>
<Introduction>
<para>在 C:\logfiles 目錄中建立名為 Log2.txt 的檔案,並將字串 "test log" 新增到此檔案。</para>
</Introduction>
<Code>
new-item -path c:\logfiles -name log2.txt -type file -value "test log"
</Code>
<Remarks>
<para></para>
</Remarks>
</Example>
</Examples>
</Task>
<Task>
<Title>
重新命名檔案和目錄
</Title>
<Description>
<para></para>
</Description>
<Examples>
<Example>
<Title>
-------------------------- 範例 1 --------------------------
</Title>
<Introduction>
<para>這個命令會將 C:\A 目錄中的檔案 A.txt 重新命名為 B.txt:</para>
</Introduction>
<Code>
rename-item -path c:\a\a.txt -newname b.txt
</Code>
<Remarks>
<para></para>
</Remarks>
</Example>
<Example>
<Title>
-------------------------- 範例 2 --------------------------
</Title>
<Introduction>
<para>這個命令會將 C:\A\Cc 目錄重新命名為 C:\A\Dd:</para>
</Introduction>
<Code>
rename-item -path c:\a\cc -newname dd
</Code>
<Remarks>
<para></para>
</Remarks>
</Example>
</Examples>
</Task>
<Task>
<Title>
刪除檔案和目錄
</Title>
<Description>
<para></para>
</Description>
<Examples>
<Example>
<Title>
-------------------------- 範例 1 --------------------------
</Title>
<Introduction>
<para>這個命令會刪除目前目錄中的 Test.txt 檔案:</para>
</Introduction>
<Code>
remove-item -path test.txt
</Code>
<Remarks>
<para></para>
</Remarks>
</Example>
<Example>
<Title>
-------------------------- 範例 2 --------------------------
</Title>
<Introduction>
<para>這個命令會刪除目前目錄中副檔名為 .xml 的所有檔案:</para>
</Introduction>
<Code>
remove-item -path *.xml
</Code>
<Remarks>
<para></para>
</Remarks>
</Example>
</Examples>
</Task>
<Task>
<Title>
透過呼叫關聯檔案來啟動程式
</Title>
<Description>
<para></para>
</Description>
<Examples>
<Example>
<Title>
-------------------------- 範例 1 --------------------------
</Title>
<Introduction>
<para>第一個命令會使用 Get-Service Cmdlet 來取得本機服務的相關資訊。
它會經由管道將資訊輸出至 Export-Csv Cmdlet,然後將該項資訊儲存在 Services.csv 檔案中。
第二個命令會使用 Invoke-Item,在與 .csv 副檔名相關聯的程式中開啟 Services.csv 檔案:</para>
</Introduction>
<Code>
get-service | export-csv -path services.csv
invoke-item -path services.csv
</Code>
<Remarks>
<para></para>
</Remarks>
</Example>
</Examples>
</Task>
</Tasks>
<DynamicParameters>
<DynamicParameter>
<Name>Encoding </Name>
<CmdletSupported>Add-Content, Get-Content, Set-Content</CmdletSupported>
<Type>
<Name>Microsoft.PowerShell.Commands.FileSystemCmdletProviderEncoding</Name>
</Type>
<Description></Description>
<PossibleValues>
<PossibleValue>
<Value>不明</Value>
<Description>
<para>編碼類型不明或無效。資料可以視為二進位格式處理。</para>
</Description>
</PossibleValue>
<PossibleValue>
<Value>String</Value>
<Description>
<para>使用字串適用的編碼類型。</para>
</Description>
</PossibleValue>
<PossibleValue>
<Value>Unicode</Value>
<Description>
<para>編碼成使用 Little-Endian 位元組順序的 UTF-16 格式。</para>
</Description>
</PossibleValue>
<PossibleValue>
<Value>Byte</Value>
<Description>
<para>將字元集編碼成位元組序列。</para>
</Description>
</PossibleValue>
<PossibleValue>
<Value>BigEndianUnicode</Value>
<Description>
<para>編碼成使用 Big-Endian 位元組順序的 UTF-16 格式。</para>
</Description>
</PossibleValue>
<PossibleValue>
<Value>UTF8</Value>
<Description>
<para>編碼成 UTF-8 格式。</para>
</Description>
</PossibleValue>
<PossibleValue>
<Value>UTF7</Value>
<Description>
<para>編碼成 UTF-7 格式。</para>
</Description>
</PossibleValue>
<PossibleValue>
<Value>ASCII</Value>
<Description>
<para>使用 ASCII (7-bit) 字元集適用的編碼類型。</para>
</Description>
</PossibleValue>
</PossibleValues>
</DynamicParameter>
<DynamicParameter>
<Name>Delimiter</Name>
<CmdletSupported>Get-Content</CmdletSupported>
<Type>
<Name>System.String</Name>
</Type>
<Description>指定在讀取檔案時所要使用的分隔字元。預設值為 "\n" (行尾)。</Description>
<PossibleValues>
</PossibleValues>
</DynamicParameter>
<DynamicParameter>
<Name>Wait</Name>
<CmdletSupported>Get-Content</CmdletSupported>
<Type>
<Name>System.Management.Automation.SwitchParameter</Name>
</Type>
<Description>等候要附加到檔案中的內容。如果已經附加內容,它會傳回該附加內容。如果內容被更改,它會傳回整個檔案。
進行等候時,Get-Content 每秒鐘都會檢查一次檔案,直到您中斷檢查 (例如,按下 CTRL+C) 為止。</Description>
<PossibleValues>
<PossibleValue>
<Value></Value>
<Description>
<para></para>
</Description>
</PossibleValue>
</PossibleValues>
</DynamicParameter>
</DynamicParameters>
<RelatedLinks>
<navigationLink>
<linkText>about_Providers</linkText>
<uri />
</navigationLink>
</RelatedLinks>
</providerHelp>
<!-- v 1.1.0.9 -->
<providerHelp>
<Name>
Function
</Name>
<Drives>
<Para>Function:</Para>
</Drives>
<Synopsis>
提供定義於 Windows PowerShell 中之函數的存取權。
</Synopsis>
<DetailedDescription>
<para>Windows PowerShell 函數提供者可讓您取得、新增、變更、清除和刪除 Windows PowerShell 中的函數和篩選器。
函數是會執行動作的已命名程式碼區塊。當您輸入函數名稱時,就會執行該函數中的程式碼。篩選器是為動作建立條件的已命名程式碼區塊。您可以輸入篩選器名稱來取代條件,例如在使用 Where-Object 命令時。
在 Function: 磁碟機中,函數的前面會加上標籤 "Function",而篩選器的前面會加上標籤 "Filter",但是無論標籤為何,它們在應用於正確內容時都會正常執行。
函數提供者是指僅包含函數和篩選器物件的一般命名空間。函數和篩選器都沒有子項目。
每個函數都是 System.Management.Automation.FunctionInfo 類別的執行個體。每個篩選器都是 System.Management.Automation.FilterInfo 類別的執行個體。
在這個一節中的範例將會顯示如何管理函數,不過篩選器也可以使用這些相同方法。
函數提供者會在 Function: 磁碟機中公開其資料存放區。若要使用函數,您可以將目前的位置變更為 Function: 磁碟機 ("set-location function:")。或者,您也可以從其他 Windows PowerShell 磁碟機執行工作。若要從其他位置參考函數,請在路徑中使用磁碟機名稱 (Function:)。
函數提供者支援名稱包含 Item 名詞的所有 Cmdlet (Item Cmdlet),但 Invoke-Item 除外。此外,它也支援 Get-Content 和 Set-Content Cmdlet。不過,它既不支援名稱包含 ItemProperty 名詞的 Cmdlet (ItemProperty Cmdlet),也不支援任何 Cmdlet 中的 Filter 參數。
任何的函數變更都只會影響目前主控台。若要儲存變更,請將函數新增至 Windows PowerShell 設定檔,或使用 Export-Console 來儲存目前的主控台。</para>
</DetailedDescription>
<Capabilities>
<para></para>
</Capabilities>
<Filters>
<para></para>
</Filters>
<Notes>
</Notes>
<Tasks>
<Task>
<Title>
切換到 Function: 磁碟機
</Title>
<Description>
<para></para>
</Description>
<Examples>
<Example>
<Title>
-------------------------- 範例 1 --------------------------
</Title>
<Introduction>
<para>將目前位置切換到 Function: 磁碟機。您可以在 Windows PowerShell 中從任何的磁碟機執行此命令。若要返回檔案系統磁碟機,請輸入磁碟機名稱。例如,請輸入 "set-location c:"。</para>
</Introduction>
<Code>
set-location function:
</Code>
<Remarks>
<para></para>
</Remarks>
</Example>
</Examples>
</Task>
<Task>
<Title>
取得函數
</Title>
<Description>
<para></para>
</Description>
<Examples>
<Example>
<Title>
-------------------------- 範例 1 --------------------------
</Title>
<Introduction>
<para>這個命令會取得目前工作階段中所有函數的清單。您可以從任何的 Windows PowerShell 磁碟機執行此命令。</para>
</Introduction>
<Code>
get-childitem -path function:
</Code>
<Remarks>
<para></para>
</Remarks>
</Example>
<Example>
<Title>
-------------------------- 範例 2 --------------------------
</Title>
<Introduction>
<para>這個命令會從 Function: 磁碟機取得 "man" 函數。它會使用 Get-Item Cmdlet 來取得此函數。管線運算子 (|) 會將結果傳送到 Format-Table。
Wrap 參數會將無法放入一行的文字導向到下一行。Autosize 參數會配合文字而調整資料表欄位大小。</para>
</Introduction>
<Code>
get-item -path man | format-table -wrap -autosize
</Code>
<Remarks>
<para>如果您位在不同的磁碟機,請將此磁碟機名稱 (Function:) 新增到路徑中。</para>
</Remarks>
</Example>
<Example>
<Title>
-------------------------- 範例 3 --------------------------
</Title>
<Introduction>
<para>這些命令都會取得名稱為 "c:" 的函數。第一個命令可以用於任何磁碟機。第二個命令可以用於 Function: 磁碟機。
因為磁碟機名稱是以冒號作為結尾,而這是磁碟機的語法,所以您必須使用磁碟機名稱限定路徑。在 Function: 磁碟機中,您可以使用任何一種格式。在第二個命令中,點 (.) 代表目前位置。</para>
</Introduction>
<Code>
c:\PS> get-item -path function:c:
PS Function> get-item -path .\c:
</Code>
<Remarks>
<para></para>
</Remarks>
</Example>
</Examples>
</Task>
<Task>
<Title>
建立函數
</Title>
<Description>
<para></para>
</Description>
<Examples>
<Example>
<Title>
-------------------------- 範例 1 --------------------------
</Title>
<Introduction>
<para>這個命令會使用 New-Item Cmdlet 來建立名為 "HKLM:" 的函數。在大括號中的運算式是由函數名稱代表的指令碼區塊。</para>
</Introduction>
<Code>
new-item -path function:hklm: -value {set-location hklm:}
</Code>
<Remarks>
<para>您也可以直接在 Windows PowerShell 命令列中輸入以建立函數。例如,請輸入 "function:hklm: {set-location hklm:}"。如果您的位置是在 Function: 磁碟機上,就可以省略磁碟機名稱。
因為您無法在 New-Item 中指定 "Filter" 標籤,所以篩選器會加上函數標籤,但是無論加上何種標籤,它們都會正常執行。若要建立包含 "Filter" 標籤的篩選器,請在命令列上輸入該篩選器。例如,請輸入 "filter:Running {$_.Status -eq "Running"}"。</para>
</Remarks>
</Example>
<Example>
<Title>
-------------------------- 範例 2 --------------------------
</Title>
<Introduction>
<para>這個命令會使用 New-Item Cmdlet 來建立名為 Csrss 的函數。它會使用 Options 動態參數,將函數的 Options 屬性值指定為 ReadOnly。</para>
</Introduction>
<Code>
new-item -path function: -name csrss -options readonly -value {get-process csrss}
</Code>
<Remarks>
<para>這個命令可從任何位置執行。如果目前的位置是 Function: 磁碟機,您就可以使用點 (.) 來指定路徑。該點代表目前位置。</para>
</Remarks>
</Example>
</Examples>
</Task>
<Task>
<Title>
刪除函數
</Title>
<Description>
<para></para>
</Description>
<Examples>
<Example>
<Title>
-------------------------- 範例 1 --------------------------
</Title>
<Introduction>
<para>這個命令會從目前的工作階段中刪除 "hklm:" 函數。</para>
</Introduction>
<Code>
remove-item function:hklm:
</Code>
<Remarks>
<para></para>
</Remarks>
</Example>
<Example>
<Title>
-------------------------- 範例 2 --------------------------
</Title>
<Introduction>
<para>這個命令會從目前的工作階段中刪除所有函數,但是 Options 屬性值為 Constant 的函數除外。如果沒有使用 Force 參數,此命令就不會刪除 Options 屬性值為 ReadOnly 的函數。</para>
</Introduction>
<Code>
remove-item function:* -force
</Code>
<Remarks>
<para>當您刪除所有的函數時,命令提示字元就會變更,因為定義命令提示字元內容的提示函數已被刪除。</para>
</Remarks>
</Example>
</Examples>
</Task>
<Task>
<Title>
顯示函數的屬性和方法
</Title>
<Description>
<para></para>
</Description>
<Examples>
<Example>
<Title>
-------------------------- 範例 1 --------------------------
</Title>
<Introduction>
<para>這個命令會使用 Get-Item Cmdlet 來取得所有函數。管線運算子會將結果傳送至 Get-Member Cmdlet,再由後者顯示物件的方法和屬性。</para>
</Introduction>
<Code>
get-item -path function:* | get-member
</Code>
<Remarks>
<para>當您經由管道將物件的集合 (例如 Function: 磁碟機中的函數集合) 輸出至 Get-Member 時,Get-Member 就會個別評估集合中的每個物件,並傳回它所找到之每種物件類型的相關資訊。如果所有的物件屬於同一類型,則傳回單一物件類型的相關資訊。在這個範例中,所有的函數都是 FunctionInfo 物件。
若要取得 FunctionInfo 物件集合的相關資訊,請使用 Get-Member 的 InputObject 參數。例如,請輸入 "get-member -InputObject (get-item function:*)"。當您使用 InputObject 參數時,Get-Member 就會評估集合,而非評估集合中的物件。</para>
</Remarks>
</Example>
<Example>
<Title>
-------------------------- 範例 2 --------------------------
</Title>
<Introduction>
<para>這個命令會列出 "prompt" 函數的屬性值。它會使用 Get-Item Cmdlet 來取得代表 "prompt" 函數的物件。管線運算子 (|) 會將結果傳送至 Format-List 命令。Format-List 命令會使用 Property 參數搭配萬用字元 (*) 來格式化並顯示 "prompt" 函數的所有屬性值。</para>
</Introduction>
<Code>
get-item function:prompt | format-list -property *
</Code>
<Remarks>
<para></para>
</Remarks>
</Example>
</Examples>
</Task>
<Task>
<Title>
變更函數的屬性
</Title>
<Description>
<para></para>
</Description>
<Examples>
<Example>
<Title>
-------------------------- 範例 1 --------------------------
</Title>
<Introduction>
<para>您可以使用 Set-Item Cmdlet 搭配 Options 動態參數來變更函數的 Options 屬性值。
此命令為 "prompt" 函數設定 AllScope 和 ReadOnly 選項。這個命令會使用 Set-Item Cmdlet 的 Options 動態參數。只有當您搭配 Alias 或 Function 提供者使用 Set-Item 時,才可以在其中使用 Options 參數。</para>
</Introduction>
<Code>
set-item -path function:prompt -options "AllScope,ReadOnly"
</Code>
<Remarks>
<para></para>
</Remarks>
</Example>
<Example>
<Title>
-------------------------- 範例 2 --------------------------
</Title>
<Introduction>
<para>此命令使用 Set-Item Cmdlet 將 "prompt" 函數變更為先顯示時間再顯示路徑。</para>
</Introduction>
<Code>
set-item -path function:prompt -value {'PS '+ $(Get-Date -format t) + " " + $(Get-Location) + '> '}
</Code>
<Remarks>
<para>這項變更會影響 FunctionInfo 物件的 Definition 和 ScriptBlock 屬性。若要查看此變更的影響,請輸入 "get-item -path function:prompt | format-list -property *"。</para>
</Remarks>
</Example>
<Example>
<Title>
-------------------------- 範例 3 --------------------------
</Title>
<Introduction>
<para>這個命令會使用 Rename-Item Cmdlet,將 "help" 函數的名稱變更成 "gh"。</para>
</Introduction>
<Code>
rename-item -path function:help -newname gh
</Code>
<Remarks>
<para></para>
</Remarks>
</Example>
</Examples>
</Task>
<Task>
<Title>
複製函數
</Title>
<Description>
<para></para>
</Description>
<Examples>
<Example>
<Title>
-------------------------- 範例 1 --------------------------
</Title>
<Introduction>
<para>這個命令會將 "prompt" 函數複製到 "oldPrompt",有效地為與此提示函數相關聯的指令碼區塊建立新名稱。若您計劃變更函數,可以使用這個命令儲存原始的提示函數。
新函數的 Options 屬性值為 None。若要變更 Options 屬性值,請使用 Set-Item。</para>
</Introduction>
<Code>
copy-item -path function:prompt -destination function:oldPrompt
</Code>
<Remarks>
<para></para>
</Remarks>
</Example>
</Examples>
</Task>
</Tasks>
<DynamicParameters>
<DynamicParameter>
<Name>Options</Name>
<CmdletSupported>New-Item, Set-Item</CmdletSupported>
<Type>
<Name>System.Management.Automation.ScopedItemOptions</Name>
</Type>
<Description>決定函數的 Options 屬性值。</Description>
<PossibleValues>
<PossibleValue>
<Value>無</Value>
<Description>
<para>沒有選項。預設值為 "None"。</para>
</Description>
</PossibleValue>
<PossibleValue>
<Value>Constant</Value>
<Description>
<para>您無法刪除函數,而且無法變更函數的屬性。只有建立函數時才能使用 Constant。您無法將現有函數的選項變更為 Constant。</para>
</Description>
</PossibleValue>
<PossibleValue>
<Value>Private</Value>
<Description>
<para>函數只會顯示於目前範圍 (不會顯示於子範圍)。</para>
</Description>
</PossibleValue>
<PossibleValue>
<Value>ReadOnly</Value>
<Description>
<para>您無法變更函數的屬性,除非使用 Force 參數。您可以使用 Remove-Item 來刪除函數。</para>
</Description>
</PossibleValue>
<PossibleValue>
<Value>AllScope</Value>
<Description>
<para>將函數複製到所有新建立的範圍。</para>
</Description>
</PossibleValue>
</PossibleValues>
</DynamicParameter>
</DynamicParameters>
<RelatedLinks>
<navigationLink>
<linkText>about_Functions</linkText>
<uri />
</navigationLink>
<navigationLink>
<linkText>about_Providers</linkText>
<uri />
</navigationLink>
</RelatedLinks>
</providerHelp>
<!-- v 1.1.0.9 -->
<providerHelp>
<Name>
Registry
</Name>
<Drives>
<Para>HKLM:、HKCU:</Para>
</Drives>
<Synopsis>
讓 Windows PowerShell 存取系統登錄機碼和值。
</Synopsis>
<DetailedDescription>
<para>Windows PowerShell 登錄提供者可以用來取得、新增、變更、清除和刪除 Windows PowerShell 中的登錄機碼和值。
登錄機碼會以 Microsoft.Win32.RegistryKey 類別的執行個體表示。登錄值會以 PSCustomObject 類別的執行個體表示。
登錄提供者可用來存取由登錄機碼和子機碼組成的階層命名空間。登錄值和資料不是該階層結構中的元件。而是各個機碼的屬性。
登錄提供者支援包含名詞 Item 的所有 Cmdlet (Item Cmdlet),例如 Get-Item、Copy-Item 和 Rename-Item。請在處理登錄機碼和子機碼時使用這些 Item Cmdlet。登錄提供者也支援包含名詞 ItemProperty 的 Cmdlet (ItemProperty Cmdlet)。請在處理登錄值和資料時使用這些 ItemProperty Cmdlet。您不能將包含名詞 Content 的 Cmdlet (Content Cmdlet) 與登錄提供者搭配使用。
每一個登錄機碼都會以安全性描述元保護。您可以使用 Get-Acl 來檢視機碼的安全性描述元。</para>
</DetailedDescription>
<Capabilities>
<para>ShouldProcess</para>
</Capabilities>
<Filters>
<para></para>
</Filters>
<Notes>
</Notes>
<Tasks>
<Task>
<Title>
瀏覽登錄
</Title>
<Description>
<para></para>
</Description>
<Examples>
<Example>
<Title>
-------------------------- 範例 1 --------------------------
</Title>
<Introduction>
<para>以下命令會將目前位置設定成 HKEY_LOCAL_MACHINE\Software 登錄機碼:</para>
</Introduction>
<Code>
set-location hklm:\software
</Code>
<Remarks>
<para></para>
</Remarks>
</Example>
<Example>
<Title>
-------------------------- 範例 2 --------------------------
</Title>
<Introduction>
<para>以下命令會顯示目前的位置:</para>
</Introduction>
<Code>
get-location
</Code>
<Remarks>
<para></para>
</Remarks>
</Example>
</Examples>
</Task>
<Task>
<Title>
管理登錄機碼
</Title>
<Description>
<para></para>
</Description>
<Examples>
<Example>
<Title>
-------------------------- 範例 1 --------------------------
</Title>
<Introduction>
<para>以下命令會顯示 HKEY_LOCAL_MACHINE\Software 登錄機碼之每個直接關係子機碼的相關資訊:</para>
</Introduction>
<Code>
get-childitem -path hklm:\software
</Code>
<Remarks>
<para></para>
</Remarks>
</Example>
<Example>
<Title>
-------------------------- 範例 2 --------------------------
</Title>
<Introduction>
<para>以下命令會在 HKCU:\Environment 子機碼底下建立 TestNew 子機碼:</para>
</Introduction>
<Code>
new-item -path hkcu:\Environment\TestNew
</Code>
<Remarks>
<para></para>
</Remarks>
</Example>
<Example>
<Title>
-------------------------- 範例 3 --------------------------
</Title>
<Introduction>
<para>以下命令會移除 HKEY_CURRENT_USER\Environment 機碼的 TestNew 子機碼:</para>
</Introduction>
<Code>
remove-item -path hkcu:\Environment\TestNew
</Code>
<Remarks>
<para></para>
</Remarks>
</Example>
<Example>
<Title>
-------------------------- 範例 4 --------------------------
</Title>
<Introduction>
<para>以下命令會將 TestNew 機碼複製到 TestCopy 子機碼:</para>
</Introduction>
<Code>
copy-item -path hkcu:\Environment\TestNew hkcu:\Environment\TestNew\TestCopy
</Code>
<Remarks>
<para></para>
</Remarks>
</Example>
<Example>
<Title>
-------------------------- 範例 5 --------------------------
</Title>
<Introduction>
<para>以下命令會顯示 HKEY_LOCAL_MACHINE\Software 登錄機碼之所有子機碼的相關資訊:</para>
</Introduction>
<Code>
get-childitem -path hklm:\Software -recurse
</Code>
<Remarks>
<para></para>
</Remarks>
</Example>
<Example>
<Title>
-------------------------- 範例 6 --------------------------
</Title>
<Introduction>
<para>以下命令會將 HKEY_CURRENT_USER\Environment\testnewcopy 登錄機碼與其屬性,以及其所有子機碼及其屬性移至 HKEY_CURRENT_USER\Environment\testnew:</para>
</Introduction>
<Code>
move-item -path hkcu:\environment\testnewcopy `
-destination hkcu:\environment\testnew
</Code>
<Remarks>
<para></para>
</Remarks>
</Example>
<Example>
<Title>
-------------------------- 範例 7 --------------------------
</Title>
<Introduction>
<para>以下命令會將 HKEY_CURRENT_USER\Environment\testnew 登錄機碼重新命名為 HKEY_CURRENT_USER\Environment\test:</para>
</Introduction>
<Code>
rename-item -path hkcu:\environment\testnew\ -newname test
</Code>
<Remarks>
<para></para>
</Remarks>
</Example>
<Example>
<Title>
-------------------------- 範例 8 --------------------------
</Title>
<Introduction>
<para>以下命令會顯示指定之登錄項目的安全性描述元:</para>
</Introduction>
<Code>
get-acl -path hkcu:\environment\testnew | format-list -property *
</Code>
<Remarks>
<para></para>
</Remarks>
</Example>
</Examples>
</Task>
<Task>
<Title>
管理登錄項目
</Title>
<Description>
<para></para>
</Description>
<Examples>
<Example>
<Title>
-------------------------- 範例 1 --------------------------
</Title>
<Introduction>
<para>以下命令會顯示 HKEY_CURRENT_USER\Environment 登錄機碼中每個登錄項目的值名稱和值資料:</para>
</Introduction>
<Code>
get-itemproperty -path hkcu:\Environment
</Code>
<Remarks>
<para>預設的登錄項目只會在其包含值的情況下傳回。</para>
</Remarks>
</Example>
<Example>
<Title>
-------------------------- 範例 2 --------------------------
</Title>
<Introduction>
<para>以下命令會顯示 HKEY_CURRENT_USER\Environment 登錄機碼中 Temp 登錄項目的值名稱和值資料:</para>
</Introduction>
<Code>
get-itemproperty -path hkcu:\Environment -name Temp
</Code>
<Remarks>
<para></para>
</Remarks>
</Example>
<Example>
<Title>
-------------------------- 範例 3 --------------------------
</Title>
<Introduction>
<para>以下命令會在 HKEY_CURRENT_USER 機碼中建立 pstest 登錄項目,並將其值設定為 pstestvalue:</para>
</Introduction>
<Code>
new-itemproperty -path hkcu:\environment -name "pstest" -value "pstestvalue"
</Code>
<Remarks>
<para></para>
</Remarks>
</Example>
<Example>
<Title>
-------------------------- 範例 4 --------------------------
</Title>
<Introduction>
<para>以下命令會將 HKEY_CURRENT_USER\Environment 機碼中 pstest 登錄項目的值更新成 updatedvalue:</para>
</Introduction>
<Code>
set-itemproperty -path hkcu:\environment -name pstest
-value "updatedvalue"
</Code>
<Remarks>
<para></para>
</Remarks>
</Example>
<Example>
<Title>
-------------------------- 範例 5 --------------------------
</Title>
<Introduction>
<para>以下命令會將 HKEY_CURRENT_USER\Environment 機碼中 pstest 登錄項目的值名稱重新命名成 pstestnew:</para>
</Introduction>
<Code>
rename-itemproperty -path hkcu:\environment -name pstest `
-newname pstestnew
</Code>
<Remarks>
<para></para>
</Remarks>
</Example>
<Example>
<Title>
-------------------------- 範例 6 --------------------------
</Title>
<Introduction>
<para>以下命令會將 HKEY_CURRENT_USER\Environment 機碼中的 pstestnew 登錄項目複製到 HKEY_CURRENT_USER\Environment\testnewcopy 機碼:</para>
</Introduction>
<Code>
copy-itemproperty -path hkcu:\environment `
-destination hkcu:\environment\testnewcopy -name pstestnew
</Code>
<Remarks>
<para></para>
</Remarks>
</Example>
<Example>
<Title>
-------------------------- 範例 7 --------------------------
</Title>
<Introduction>
<para>以下命令會將 HKEY_CURRENT_USER\environment\testnewcopy 機碼中的 pstestnew 登錄項目移至 HKEY_CURRENT_USER\environment\testnew 機碼:</para>
</Introduction>
<Code>
move-itemproperty -path hkcu:\environment\testnewcopy '
-destination hkcu:\environment\testnew -name pstestnew
</Code>
<Remarks>
<para></para>
</Remarks>
</Example>
<Example>
<Title>
-------------------------- 範例 8 --------------------------
</Title>
<Introduction>
<para>以下命令會清除 HKEY_CURRENT_USER\Environment\testnew 機碼中 pstestnew 登錄項目的值:</para>
</Introduction>
<Code>
clear-itemproperty -path hkcu:\environment\testnew -name pstestnew
</Code>
<Remarks>
<para>您可以使用 Clear-Item Cmdlet 為子機碼清除預設的登錄項目值。例如,以下命令會清除 HKEY_CURRENT_USER\Environment\testnew 登錄機碼之預設項目的值:
clear-item -path hkcu:\environment\testnew</para>
</Remarks>
</Example>
<Example>
<Title>
-------------------------- 範例 9 --------------------------
</Title>
<Introduction>
<para>以下命令會移除 HKEY_CURRENT_USER\Environment\testnew 登錄機碼中的 pstestnew 登錄項目:</para>
</Introduction>
<Code>
remove-itemproperty -path hkcu:\environment\testnew `
-name pstestnew
</Code>
<Remarks>
<para></para>
</Remarks>
</Example>
<Example>
<Title>
-------------------------- 範例 10 --------------------------
</Title>
<Introduction>
<para>以下命令會將 HKEY_CURRENT_USER\Environment\testnew 機碼中預設登錄項目的值更新成 "default value":</para>
</Introduction>
<Code>
set-itemproperty -path hkcu:\environment\testnew `
-name "(default)" -value "default value"
</Code>
<Remarks>
<para>您也可以使用 Set-Item Cmdlet 來更新登錄機碼的預設值。例如,以下命令會更新 testnew 機碼的預設值:
set-item -path hkcu:\environment\testnew -value "another default value"</para>
</Remarks>
</Example>
</Examples>
</Task>
</Tasks>
<DynamicParameters>
<DynamicParameter>
<Name>Type</Name>
<CmdletSupported>Set-Item</CmdletSupported>
<Type>
<Name>Microsoft.Win32.RegistryValueKind</Name>
</Type>
<Description>指定在登錄中儲存值時所要使用的資料類型,或識別登錄中值的資料類型。</Description>
<PossibleValues>
<PossibleValue>
<Value>String</Value>
<Description>
<para>指定 null 值結束字串。作用相當於 REG_SZ。</para>
</Description>
</PossibleValue>
<PossibleValue>
<Value>ExpandString</Value>
<Description>
<para>指定 null 值結束字串,其中包含環境變數的未展開參考,這些參考會在擷取值時展開。作用相當於 REG_EXPAND_SZ。</para>
</Description>
</PossibleValue>
<PossibleValue>
<Value>Binary</Value>
<Description>
<para>指定任何形式的二進位資料。作用相當於 REG_BINARY。</para>
</Description>
</PossibleValue>
<PossibleValue>
<Value>DWord</Value>
<Description>
<para>指定 32 位元二進位數字。作用相當於 REG_DWORD。</para>
</Description>
</PossibleValue>
<PossibleValue>
<Value>MultiString</Value>
<Description>
<para>指定以兩個 null 字元結束的 null 值結束字串陣列。作用相當於 REG_MULTI_SZ。</para>
</Description>
</PossibleValue>
<PossibleValue>
<Value>QWord</Value>
<Description>
<para>指定 64 位元二進位數字。作用相當於 REG_QWORD。</para>
</Description>
</PossibleValue>
<PossibleValue>
<Value>不明</Value>
<Description>
<para>表示不支援的登錄資料類型,例如 REG_RESOURCE_LIST。</para>
</Description>
</PossibleValue>
</PossibleValues>
</DynamicParameter>
</DynamicParameters>
<RelatedLinks>
<navigationLink>
<linkText>about_Providers</linkText>
<uri />
</navigationLink>
</RelatedLinks>
</providerHelp>
<!-- v 1.1.0.9 -->
<providerHelp>
<Name>
Variable
</Name>
<Drives>
<Para>Variable:</Para>
</Drives>
<Synopsis>
提供 Windows PowerShell 變數及其值的存取權。
</Synopsis>
<DetailedDescription>
<para>Windows PowerShell Variable 提供者可以用來取得、新增、變更、清除和刪除目前主控台中的 Windows PowerShell 變數。
Windows PowerShell Variable 提供者支援 Windows PowerShell 所建立的變數,包括自動變數、喜好設定變數,以及您所建立的變數。
Variable 提供者是指僅包含變數物件的一般命名空間。變數沒有子項目。
大多數的變數是 System.Management.Automation.PSVariable 類別的執行個體。不過,還是有部分變異。例如,"?" 變數是 QuestionMarkVariable 類別的成員,而 "MaximumVariableCount" 變數是 SessionStateCapacityVariable 類別的成員。
Variable 提供者會在 Variable: 磁碟機中公開其資料存放區。若要使用變數,您可以將目前的位置變更為 Variable: 磁碟機 ("set-location variable:"),也可以從其他任何 Windows PowerShell 磁碟機執行工作。若要從其他位置參考變數,請在路徑中使用磁碟機名稱 (Variable:)。
Windows PowerShell 包括了一組專門設計用來檢視和變更變數的 Cmdlet:
-- Get-Variable
-- New-Variable
-- Set-Variable
-- Remove-Variable
-- Clear-Variable
使用這些 Cmdlet 時,並不需要在名稱中指定 Variable: 磁碟機。
Variable 提供者支援名稱包含 Item 名詞的所有 Cmdlet (Item Cmdlet),但 Invoke-Item 除外。此外,Variable 提供者支援 Get-Content 和 Set-Content Cmdlet。不過,它既不支援名稱包含 ItemProperty 名詞的 Cmdlet (ItemProperty Cmdlet),也不支援任何 Cmdlet 中的 Filter 參數。
您也可以不使用這些 Cmdlet,而使用 Windows PowerShell 運算式剖析器來建立、檢視和變更變數的值。如果是直接處理變數,請使用貨幣符號 ($) 將名稱識別為變數,並用指定運算子 (=) 建立和變更變數值。例如,"$p = get-process" 會建立 "p" 變數並在其中儲存 "get-process" 命令的結果。
變數的所有變更都只會影響目前的工作階段。若要儲存變更,請將變更新增至 Windows PowerShell 設定檔,或使用 Export-Console 來儲存目前的主控台。</para>
</DetailedDescription>
<Capabilities>
<para></para>
</Capabilities>
<Filters>
<para></para>
</Filters>
<Notes>
Variable 提供者不支援任何動態參數。
</Notes>
<Tasks>
<Task>
<Title>
切換到 Variable: 磁碟機
</Title>
<Description>
<para></para>
</Description>
<Examples>
<Example>
<Title>
-------------------------- 範例 1 --------------------------
</Title>
<Introduction>
<para>這個命令會將目前的位置變更為 Variable: 磁碟機。您可以在 Windows PowerShell 中從任何的磁碟機執行此命令。若要返回檔案系統磁碟機,請輸入磁碟機名稱。例如,請輸入 "set-location c:"。</para>
</Introduction>
<Code>
set-location variable:
</Code>
<Remarks>
<para></para>
</Remarks>
</Example>
</Examples>
</Task>
<Task>
<Title>
顯示變數的值
</Title>
<Description>
<para></para>
</Description>
<Examples>
<Example>
<Title>
-------------------------- 範例 1 --------------------------
</Title>
<Introduction>
<para>這個命令會取得目前工作階段中所有變數及其值的清單。您可以從任何的 Windows PowerShell 磁碟機執行此命令。</para>
</Introduction>
<Code>
get-childitem -path variable:
</Code>
<Remarks>
<para></para>
</Remarks>
</Example>
<Example>
<Title>
-------------------------- 範例 2 --------------------------
</Title>
<Introduction>
<para>這個命令會取得名稱以 "max" 為開頭的變數。您可以從任何的 Windows PowerShell 磁碟機執行此命令。</para>
</Introduction>
<Code>
get-childitem -path variable:max*
</Code>
<Remarks>
<para>如果目前的位置是 Variable: 磁碟機,您就可以在路徑中省略磁碟機名稱。</para>
</Remarks>
</Example>
<Example>
<Title>
-------------------------- 範例 3 --------------------------
</Title>
<Introduction>
<para>這個命令會在命令列中輸入 WhatIfPreference 變數,藉以取得此變數的值。
變數名稱的前面會加上貨幣符號 ($) 指出其為變數。不指定 Variable: 磁碟機名稱。</para>
</Introduction>
<Code>
$WhatIfPreference
</Code>
<Remarks>
<para></para>
</Remarks>
</Example>
<Example>
<Title>
-------------------------- 範例 4 --------------------------
</Title>
<Introduction>
<para>這個命令會使用 Get-ChildItem 的 LiteralPath 參數,從 Variable: 磁碟機內部取得 "?" 變數的值。Get-ChildItem 不會嘗試解析 LiteralPath 參數值中的任何萬用字元。</para>
</Introduction>
<Code>
get-childitem -literalpath ?
</Code>
<Remarks>
<para>若要不使用 cmdlet 便顯示包含特殊字元名稱之變數的值,請輸入貨幣符號 ($) 和變數名稱。例如,若要顯示 "?" 變數的值,請輸入 "$?"。</para>
</Remarks>
</Example>
<Example>
<Title>
-------------------------- 範例 5 --------------------------
</Title>
<Introduction>
<para>這個命令會取得 Options 屬性值為 "ReadOnly" 或 "Constant" 的變數。</para>
</Introduction>
<Code>
get-childitem -path variable: | where-object {$_.options -match "Constant" -or $_.options -match "ReadOnly"} | format-list -property name, value, options
</Code>
<Remarks>
<para></para>
</Remarks>
</Example>
</Examples>
</Task>
<Task>
<Title>
建立新變數
</Title>
<Description>
<para></para>
</Description>
<Examples>
<Example>
<Title>
-------------------------- 範例 1 --------------------------
</Title>
<Introduction>
<para>這個命令會建立 "services" 變數,並在其中儲存 Get-Service 命令的結果。因為目前位置是 Variable: 磁碟機,所以 Path 參數的值會用點 (.) 來代表目前位置。
括住 Get-Service 命令的括號可確保此命令會先執行,然後才建立變數。如果沒有使用括號,新變數的值就會是 "Get-Service" 字串。</para>
</Introduction>
<Code>
new-item -path . -name services -value (Get-Service)
</Code>
<Remarks>
<para>如果您的位置不是在 variable: 磁碟機,請在路徑中包括 Variable: 磁碟機名稱。</para>
</Remarks>
</Example>
<Example>
<Title>
-------------------------- 範例 2 --------------------------
</Title>
<Introduction>
<para>這個命令會建立 "services" 變數,並在其中儲存 Get-Service 命令的結果。
此命令會使用貨幣符號 ($) 指出變數,並使用指派運算子 (=) 將 Get-Service 命令的結果指派給新建立的變數。</para>
</Introduction>
<Code>
$services = Get-Service
</Code>
<Remarks>
<para>若要建立不包含值的變數,請省略指派運算子。</para>
</Remarks>
</Example>
</Examples>
</Task>
<Task>
<Title>
顯示變數的屬性和方法
</Title>
<Description>
<para></para>
</Description>
<Examples>
<Example>
<Title>
-------------------------- 範例 1 --------------------------
</Title>
<Introduction>
<para>這個命令會使用 Get-Item Cmdlet 來取得所有變數。管線運算子 (|) 會將結果傳送至 Get-Member Cmdlet,再由後者顯示物件的方法和屬性。</para>
</Introduction>
<Code>
get-item -path variable:* | get-member
</Code>
<Remarks>
<para>當您經由管道將物件的集合 (例如 Variable: 磁碟機中的變數集合) 輸出至 Get-Member 時,Get-Member 就會個別評估集合中的每個物件,並傳回它所找到之每種物件類型的相關資訊。
若要取得 Variable: 磁碟機中物件集合的相關資訊,請使用 Get-Member 的 InputObject 參數。例如 "get-member -inputobject (get-item variable:*)"。當您使用 InputObject 時,Get-Member 就會評估集合,而非評估集合中的物件。</para>
</Remarks>
</Example>
<Example>
<Title>
-------------------------- 範例 2 --------------------------
</Title>
<Introduction>
<para>這個命令會列出 "home" 變數的屬性值。它會使用 Get-Item Cmdlet 來取得代表 "home" 變數的物件。管線運算子 (|) 會將結果傳送至 Format-List 命令。Format-List 命令會使用 Property 參數搭配萬用字元 (*) 來格式化並顯示 "home" 變數的所有屬性值。</para>
</Introduction>
<Code>
get-item variable:home | format-list -property *
</Code>
<Remarks>
<para></para>
</Remarks>
</Example>
</Examples>
</Task>
<Task>
<Title>
變更變數的屬性
</Title>
<Description>
<para></para>
</Description>
<Examples>
<Example>
<Title>
-------------------------- 範例 1 --------------------------
</Title>
<Introduction>
<para>這個命令會使用 Rename-Item Cmdlet,將 "a" 變數的名稱變更成 "processes"。</para>
</Introduction>
<Code>
rename-item -path variable:a -newname processes
</Code>
<Remarks>
<para></para>
</Remarks>
</Example>
<Example>
<Title>
-------------------------- 範例 2 --------------------------
</Title>
<Introduction>
<para>這個命令會使用 Set-Item Cmdlet 將 ErrorActionPreference 變數的值變更成 "Stop"。</para>
</Introduction>
<Code>
set-item -path variable:ErrorActionPreference -value Stop
</Code>
<Remarks>
<para></para>
</Remarks>
</Example>
<Example>
<Title>
-------------------------- 範例 3 --------------------------
</Title>
<Introduction>
<para>這個命令會將 ErrorActionPreference 變數的值變更為 "Stop"。
它會使用貨幣符號 ($) 指出變數,並使用指定運算子 (=) 指定其值。</para>
</Introduction>
<Code>
$ErrorActionPreference = Stop
</Code>
<Remarks>
<para></para>
</Remarks>
</Example>
</Examples>
</Task>
<Task>
<Title>
複製變數
</Title>
<Description>
<para></para>
</Description>
<Examples>
<Example>
<Title>
-------------------------- 範例 1 --------------------------
</Title>
<Introduction>
<para>這個命令會使用 Copy-Item Cmdlet 將 "processes" 變數複製到 "old_processes"。這個動作會建立與 "processes" 變數具有相同值且名為 "old_processes" 的新變數。</para>
</Introduction>
<Code>
copy-item -path variable:processes -destination variable:old_processes
</Code>
<Remarks>
<para>如果此命令是從 Variable: 磁碟機內部發出,您就可以在 Path 參數的值中省略磁碟機名稱。</para>
</Remarks>
</Example>
<Example>
<Title>
-------------------------- 範例 2 --------------------------
</Title>
<Introduction>
<para>這個命令會將 "processes" 變數複製到 "old_processes",而不使用 cmdlet。它會使用貨幣符號 ($) 指出變數,並使用指定運算子將 $processes 的值指定到 old_processes。</para>
</Introduction>
<Code>
$old_processes = $processes
</Code>
<Remarks>
<para></para>
</Remarks>
</Example>
</Examples>
</Task>
<Task>
<Title>
刪除變數
</Title>
<Description>
<para></para>
</Description>
<Examples>
<Example>
<Title>
-------------------------- 範例 1 --------------------------
</Title>
<Introduction>
<para>這個命令會從目前的工作階段中刪除 "serv" 變數。您可以在任何的 Windows PowerShell 磁碟機上執行此命令。</para>
</Introduction>
<Code>
remove-variable -path variable:serv
</Code>
<Remarks>
<para></para>
</Remarks>
</Example>
<Example>
<Title>
-------------------------- 範例 2 --------------------------
</Title>
<Introduction>
<para>這個命令會從目前的工作階段中刪除所有變數,但是 Options 屬性值為 Constant 的變數除外。如果沒有使用 Force 參數,此命令就不會刪除 Options 屬性值為 ReadOnly 的變數。</para>
</Introduction>
<Code>
remove-item variable:* -force
</Code>
<Remarks>
<para></para>
</Remarks>
</Example>
</Examples>
</Task>
<Task>
<Title>
將變數的值設定為 NULL
</Title>
<Description>
<para></para>
</Description>
<Examples>
<Example>
<Title>
-------------------------- 範例 1 --------------------------
</Title>
<Introduction>
<para>這個命令會使用 Clear-Item Cmdlet 將 "processes" 變數的值變更成 NULL。</para>
</Introduction>
<Code>
clear-item -path variable:processes
</Code>
<Remarks>
<para></para>
</Remarks>
</Example>
<Example>
<Title>
-------------------------- 範例 2 --------------------------
</Title>
<Introduction>
<para>這個命令透過為變數指定 NULL 值的方式清除 "processes" 變數的值。它會使用 $null 自動變數來代表 NULL 值。</para>
</Introduction>
<Code>
$processes = $null
</Code>
<Remarks>
<para></para>
</Remarks>
</Example>
</Examples>
</Task>
</Tasks>
<DynamicParameters>
</DynamicParameters>
<RelatedLinks>
<navigationLink>
<linkText>about_Variables</linkText>
<uri />
</navigationLink>
<navigationLink>
<linkText>about_Automatic_Variables</linkText>
<uri />
</navigationLink>
<navigationLink>
<linkText>about_Providers</linkText>
<uri />
</navigationLink>
</RelatedLinks>
</providerHelp>
</helpItems>