WindowsOptionalFeature
概要
啟用或停用 Windows 選用功能。
語法
WindowsOptionalFeature [String] #ResourceName
{
Name = [string]
[DependsOn = [string[]]]
[Ensure = [string]{ Absent | Present }]
[LogLevel = [string]{ ErrorsAndWarning | ErrorsAndWarningAndInformation | ErrorsOnly }]
[LogPath = [string]]
[NoWindowsUpdateCheck = [bool]]
[PsDscRunAsCredential = [PSCredential]]
[RemoveFilesOnDisable = [bool]]
}
描述
資源 WindowsOptionalFeature
可讓您確保 Windows 用戶端電腦上是否啟用或停用 Windows 選擇性功能。 若要管理 Windows Server 的角色和功能,請使用 WindowsFeature 資源。
規格需求
- 目的電腦必須執行 Windows 用戶端作業系統、Windows Server 2012或更新版本,或 Nano Server。
- 目的電腦必須能夠存取 DISM PowerShell 模組
索引鍵內容
名稱
將 Windows 選用功能的名稱指定為字串。
此屬性的這個值應該與 Windows 選用功能的 FeatureName 屬性相同。 若要列出電腦的可用選擇性功能,請使用 Get-WindowsOptionalFeature
Cmdlet。
Type: System.String
選擇性屬性
Ensure
指定是否應該啟用 Windows 選用功能。 將此屬性設定為 , Present
以在停用時啟用 Windows 選用功能。 如果啟用此屬性,請將此屬性設定為 Absent
,以停用 Windows 選擇性功能。
預設值是 Present
。
Type: System.String
Accepted Values:
- Absent
- Present
Default Value: Present
LogLevel
指定要在 DISM 記錄中顯示為字串的輸出資訊。 有效選項包括:
ErrorsOnly
- 資源只會記錄錯誤。ErrorsAndWarning
- 資源會記錄錯誤和警告。ErrorsAndWarningAndInformation
- 資源會記錄錯誤、警告和偵錯資訊。
預設值是 ErrorsAndWarningAndInformation
。
Type: System.String
Accepted Values:
- ErrorsOnly
- ErrorsAndWarning
- ErrorsAndWarningAndInformation
Default Value: ErrorsAndWarningAndInformation
LogPath
指定檔案的路徑,以記錄 Windows 選擇性功能的啟用或停用。
如果未設定,資源會將記錄 %WINDIR%\Logs\Dism\dism.log
檔寫入 。
Type: System.String
Default Value: None
NoWindowsUpdateCheck
指定在搜尋來源檔案以啟用 Windows 選擇性功能時,DISM 連絡人是否Windows Update (WU) 。 將此屬性設定為 $true
,以防止 DISM 連絡 WU。
預設值是 $false
。
Type: System.Boolean
Default Value: false
RemoveFilesOnDisable
指定資源是否應該在停用時移除與 Windows 選用功能相關聯的所有檔案。 將此屬性設定為 $true
,以移除所有相關聯的檔案。
預設值是 $false
。
Type: System.Boolean
Default Value: false
唯讀屬性
CustomProperties
Windows 選用功能的自訂屬性做為字串陣列。
Type: System.String[]
描述
Windows 選用功能的描述為字串。
Type: System.String
DisplayName
Windows 選用功能的顯示名稱做為字串。
Type: System.String
範例
意見反應
https://aka.ms/ContentUserFeedback。
即將登場:在 2024 年,我們將逐步淘汰 GitHub 問題作為內容的意見反應機制,並將它取代為新的意見反應系統。 如需詳細資訊,請參閱:提交並檢視相關的意見反應