-
Notifications
You must be signed in to change notification settings - Fork 9
Test ModuleExist
Checks if a PowerShell module with a specified name is available in a
$env:PSModulePath
.
Test-ModuleExist [-Name <String>] [-Version <String>] [<CommonParameters>]
Test-ModuleExist [-Name <String>] -Path <String> [-Version <String>]
[<CommonParameters>]
Test-ModuleExist [-Name <String>] -Scope <String> [-Version <String>]
[<CommonParameters>]
The Test-ModuleExist function checks if a PowerShell module with the specified
name is available in a $env:PSModulePath
.
It can also filter the modules based on
the scope or folder path.
Additionally, it can filter the modules based on
a specific version.
See also Assert-Module
.
Test-ModuleExist -Name 'MyModule' -Scope 'CurrentUser'
Checks if a module named 'MyModule' exists in the current user's module scope.
Test-ModuleExist -Name 'MyModule' -Path 'C:\Modules'
Checks if a module named 'MyModule' exists in the specified path.
Test-ModuleExist -Name 'MyModule' -Path 'local/share/powershell/Module'
Checks if a module named 'MyModule' exists in a $env:PSModulePath
that
matches the specified path.
If for example 'MyModule' exist in the path
/home/username/.local/share/powershell/Module
it returns $true
.
Test-ModuleExist -Name 'MyModule' -Version '1.0.0'
Checks if a module named 'MyModule' with version '1.0.0' exists.
The name of the module to check is available.
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
The path where the module should be available.
This parameter is used to
filter the modules based on the path.
The specified path must match (fully
or partially) one of the $env:PSModulePath
paths.
Type: String
Parameter Sets: Path
Aliases:
Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
The scope where the module should be available. This parameter is used to filter the modules based on the scope.
Type: String
Parameter Sets: Scope
Aliases:
Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
The version of the module. This parameter is used to filter the modules based on a specific version.
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.
- Assert-BoundParameter
- Assert-ElevatedUser
- Assert-IPAddress
- Assert-Module
- Compare-DscParameterState
- Compare-ResourcePropertyState
- ConvertFrom-DscResourceInstance
- ConvertTo-CimInstance
- ConvertTo-HashTable
- Find-Certificate
- Get-ComputerName
- Get-DscProperty
- Get-EnvironmentVariable
- Get-LocalizedData
- Get-LocalizedDataForInvariantCulture
- Get-PSModulePath
- Get-TemporaryFolder
- Get-UserName
- New-ArgumentException
- New-ErrorRecord
- New-Exception
- New-InvalidDataException
- New-InvalidOperationException
- New-InvalidResultException
- New-NotImplementedException
- New-ObjectNotFoundException
- Remove-CommonParameter
- Set-DscMachineRebootRequired
- Set-PSModulePath
- Test-AccountRequirePassword
- Test-DscParameterState
- Test-DscProperty
- Test-IsNanoServer
- Test-IsNumericType
- Test-ModuleExist