Indicates whether a variable has been defined.
Test-Variable.ps1 [-Name] <String> [[-Scope] <String>] [-ProgressAction <ActionPreference>]
[<CommonParameters>]
Test-Variable.ps1 true
True
Test-Variable.ps1 ''
False
A variable can’t have an empty string for a name.
Test-Variable.ps1 $null
False
A variable can’t have a null name.
Test-Variable.ps1 null
True
'PSVersionTable','false' |Test-Variable.ps1
True True
'PWD','PID' |Test-Variable.ps1 -Scope Global
True True
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
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 2
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Type: ActionPreference
Parameter Sets: (All)
Aliases: proga
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.