Skip to content

Assert Module

dscbot edited this page Feb 13, 2024 · 2 revisions

Assert-Module

SYNOPSIS

Assert if the specific module is available to be imported and optionally import the module.

SYNTAX

Assert-Module [-ModuleName] <String> [-ImportModule] [-Force] 
 [<CommonParameters>]

DESCRIPTION

Assert if the specific module is available to be imported and optionally import the module. If the module is not available an exception will be thrown.

See also Test-ModuleExist.

EXAMPLES

EXAMPLE 1

Assert-Module -ModuleName 'DhcpServer'

This asserts that the module DhcpServer is available on the system. If it is not an exception will be thrown.

EXAMPLE 2

Assert-Module -ModuleName 'DhcpServer' -ImportModule

This asserts that the module DhcpServer is available on the system and imports it. If the module is not available an exception will be thrown.

EXAMPLE 3

Assert-Module -ModuleName 'DhcpServer' -ImportModule -Force

This asserts that the module DhcpServer is available on the system and it will be forcibly imported into the session (even if it was already in the session). If the module is not available an exception will be thrown.

PARAMETERS

-Force

Specifies to forcibly import the module even if it is already in the session. This parameter is ignored unless parameter ImportModule is also used.

Type: SwitchParameter
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False

-ImportModule

Specifies to import the module if it is asserted.

Type: SwitchParameter
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False

-ModuleName

Specifies the name of the module to assert.

Type: String
Parameter Sets: (All)
Aliases:

Required: True
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

INPUTS

OUTPUTS

NOTES

RELATED LINKS

Clone this wiki locally