Skip to content

Test Variable

github-actions edited this page Jul 4, 2026 · 2 revisions

external help file: ModernConveniences-help.xml Module Name: ModernConveniences online version: schema: 2.0.0

Test-Variable

SYNOPSIS

Indicates whether a variable has been defined.

SYNTAX

Test-Variable [-Name] <String> [-SessionState <SessionState>] [-ProgressAction <ActionPreference>]
 [<CommonParameters>]

DESCRIPTION

{{ Fill in the Description }}

EXAMPLES

EXAMPLE 1

Test-Variable true

True

EXAMPLE 2

Test-Variable ''

False

A variable can't have an empty string for a name.

EXAMPLE 3

Test-Variable $null

False

A variable can't have a null name.

EXAMPLE 4

Test-Variable null

True

EXAMPLE 5

'PSVersionTable','false' |Test-Variable

True True

EXAMPLE 6

'PWD','PID' |Test-Variable -Scope Global

True True

PARAMETERS

-Name

A variable name to test the existence of.

Type: String
Parameter Sets: (All)
Aliases:

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

-SessionState

The SessionState object to use to access the variables.

Type: SessionState
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: $ExecutionContext.SessionState.Module.GetVariableFromCallersModule('PSCmdlet')?.Value?.SessionState
Accept pipeline input: False
Accept wildcard characters: False

-ProgressAction

{{ Fill ProgressAction Description }}

Type: ActionPreference
Parameter Sets: (All)
Aliases: proga

Required: False
Position: Named
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

System.String name of a variable.

OUTPUTS

System.Boolean indicating whether the variable name is defined.

NOTES

RELATED LINKS

Get-Variable

Clone this wiki locally