Share via


WindowsFeature

概要

安裝或卸載 Windows 角色或功能。

語法

WindowsFeature [String] #ResourceName
{
    Name = [string]
    [Credential = [PSCredential]]
    [DependsOn = [string[]]]
    [Ensure = [string]{ Absent | Present }]
    [IncludeAllSubFeature = [bool]]
    [LogPath = [string]]
    [PsDscRunAsCredential = [PSCredential]]
}

描述

資源 WindowsFeature 可讓您確保 Windows 角色或功能是安裝在 Windows Server 上。 若要管理用戶端電腦,請使用 WindowsOptionalFeature 資源

規格需求

  • 目的電腦必須執行 Windows Server 2008 或更新版本。
  • 目的電腦必須能夠存取 DISM PowerShell 模組。
  • 目的電腦必須能夠存取 ServerManager PowerShell 模組。

屬性

金鑰屬性

名稱

將角色或功能的名稱指定為字串。

此屬性的這個值應該與角色或功能的 Name 屬性相同,而不是 DisplayName 屬性。 若要列出電腦的可用角色和功能,請使用 Get-WindowsFeature Cmdlet。

Type: System.String

選擇性屬性

認證

指定要新增或移除角色或功能之帳戶的認證。

Type: System.Management.Automation.PSCredential
Default Value: None

Ensure

指定是否應該安裝角色或功能。 如果尚未安裝,請將此屬性設定為 Present ,以安裝角色或功能。 將此屬性設定為 Absent ,以在安裝角色或功能時卸載。

預設值是 Present

Type: System.String
Accepted Values:
  - Absent
  - Present
Default Value: Present

IncludeAllSubFeature

指定是否要安裝功能或角色的每個子功能。 將此屬性設定為 $true ,以安裝任何遺漏的子功能。 將此屬性設定為 $false 以忽略子功能。 不論此屬性的設定為何,如果 [確定 ] 設定為 Absent ,則資源會移除所有子功能。

預設值是 $false

Type: System.Boolean
Behavior: Write
Default Value: false

LogPath

指定檔案的路徑,以記錄功能或角色的安裝或卸載。

Type: System.String
Default Value: None

唯讀屬性

DisplayName

所擷取角色或功能的顯示名稱。

Type: System.String

範例