Skip to content

Function ServerFeature

Mark Wragg edited this page Jun 17, 2019 · 1 revision

ServerFeature

SYNOPSIS

Test if a Windows Server feature is installed.

DESCRIPTION

Uses the Get-WindowsFeature cmdlet to test if a Windows feature is installed.

This cmdlet does not work on a desktop operating system to retieve the list of locally installed features and as such is not currently supported on the desktop.

PARAMETERS

Target [String]

The Windows Server feature name to test.

[Parameter(Mandatory, Position=1)]

Property [String]

The optional property on the feature to test for. If not specified, will default to the 'Installed' property.

[Parameter(Position=2, ParameterSetName='prop')]
        [ValidateSet(
            'BestPracticesModelId',
            'DependsOn',
            'Depth',
            'DisplayName',
            'FeatureType',
            'Installed',
            'InstallState',
            'Name',
            'Notification',
            'Parent',
            'Path',
            'ServerComponentDescriptor',
            'SubFeatures',
            'SystemService'
        )]

Should [ScriptBlock]

A Script Block defining a Pester Assertion.

[Parameter(Mandatory, Position=2, ParameterSetName='noprop')]
[Parameter(Mandatory, Position=3, ParameterSetName='prop')]

Assertions

Assertions: -Be, -BeNullOrEmpty

EXAMPLES

-------------------------- EXAMPLE 1 --------------------------

ServerFeature Web-Server { Should be $true }

-------------------------- EXAMPLE 2 --------------------------

ServerFeature TelnetClient { Should -Be $false }

-------------------------- EXAMPLE 3 --------------------------

ServerFeature Web-Server InstallState { Should -Be 'Installed' }

-------------------------- EXAMPLE 4 --------------------------

ServerFeature Remote-Access InstallState { Should -Be 'Available' }