mirror of
https://github.com/inspec/inspec
synced 2024-11-23 21:23:29 +00:00
f2d64938b7
* windows_feature resource: Add DISM support This modifies the `windows_feature` resource to fallback to DISM when the `Get-WindowsFeature` command is not available. * Allow specifying `:dism` or `:powershell` * Replace stacktrace with smaller error message * Add notes/todo about raise behavior * Remove duplicated platform check Signed-off-by: Jerry Aldrich <jerryaldrichiii@gmail.com>
59 lines
1.4 KiB
Text
59 lines
1.4 KiB
Text
---
|
|
title: About the windows_feature Resource
|
|
platform: windows
|
|
---
|
|
|
|
# windows_feature
|
|
|
|
Use the `windows_feature` InSpec audit resource to test features on Windows via the `Get-WindowsFeature` cmdlet.
|
|
|
|
<br>
|
|
|
|
## Syntax
|
|
|
|
A `windows_feature` resource block declares the name of the Windows feature, tests if that feature is installed, and then returns information about that feature:
|
|
|
|
describe windows_feature('feature_name') do
|
|
it { should be_installed }
|
|
end
|
|
|
|
where
|
|
|
|
* `('feature_name')` must specify a Windows feature name, such as `DHCP Server` or `IIS-Webserver`
|
|
* `be_installed` is a valid matcher for this resource
|
|
|
|
<br>
|
|
|
|
## Examples
|
|
|
|
The following examples show how to use this InSpec audit resource.
|
|
|
|
### Test the DHCP feature (Attempts PowerShell then DISM)
|
|
|
|
describe windows_feature('DHCP') do
|
|
it{ should be_installed }
|
|
end
|
|
|
|
### Test the IIS-WebServer feature using DISM
|
|
|
|
describe windows_feature('IIS-WebServer', DISM) do
|
|
it{ should be_installed }
|
|
end
|
|
|
|
### Test the NetFx3 feature using DISM
|
|
|
|
describe windows_feature('NetFx3', :dism) do
|
|
it{ should be_installed }
|
|
end
|
|
|
|
<br>
|
|
|
|
## Matchers
|
|
|
|
For a full list of available matchers, please visit our [matchers page](https://www.inspec.io/docs/reference/matchers/).
|
|
|
|
### be_installed
|
|
|
|
The `be_installed` matcher tests if the named Windows feature is installed:
|
|
|
|
it { should be_installed }
|