Remove-HashtableEntry¶
SYNOPSIS¶
Removes specific entries from a hashtable based on given criteria.
SYNTAX¶
__AllParameterSets¶
Remove-HashtableEntry [-Hashtable] <hashtable> [[-Types] <string[]>] [[-Keys] <string[]>]
[[-KeepTypes] <string[]>] [[-KeepKeys] <string[]>] [-NullOrEmptyValues] [-KeepNullOrEmptyValues]
[-All] [<CommonParameters>]
ALIASES¶
This cmdlet has the following aliases, {{Insert list of aliases}}
DESCRIPTION¶
This function filters out entries from a hashtable based on different conditions.
You can remove keys with
null or empty values, keys of a specific type, or keys matching certain names.
It also allows keeping entries
based on the opposite criteria.
If the -All parameter is used, all entries in the hashtable will be removed.
EXAMPLES¶
EXAMPLE 1¶
$myHashtable = @{ Name = 'John'; Age = 30; Country = $null } $myHashtable | Remove-HashtableEntry -NullOrEmptyValues
Output:
@{ Name = 'John'; Age = 30 }
Removes entries with null or empty values from the hashtable.
EXAMPLE 2¶
$myHashtable = @{ Name = 'John'; Age = 30; Active = $true } $myHashtable | Remove-HashtableEntry -Types 'Boolean'
Output:
@{ Name = 'John'; Age = 30 }
Removes entries where the value type is Boolean.
EXAMPLE 3¶
$myHashtable = @{ Name = 'John'; Age = 30; Country = 'USA' } $myHashtable | Remove-HashtableEntry -Keys 'Age'
Output:
@{ Name = 'John'; Country = 'USA' }
Removes the key 'Age' from the hashtable.
PARAMETERS¶
-All¶
Remove all entries from the hashtable.
Type: System.Management.Automation.SwitchParameter
DefaultValue: False
SupportsWildcards: false
Aliases: []
ParameterSets:
- Name: (All)
Position: Named
IsRequired: false
ValueFromPipeline: false
ValueFromPipelineByPropertyName: false
ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''
-Hashtable¶
The hashtable to remove entries from.
Type: System.Collections.Hashtable
DefaultValue: ''
SupportsWildcards: false
Aliases: []
ParameterSets:
- Name: (All)
Position: 0
IsRequired: true
ValueFromPipeline: true
ValueFromPipelineByPropertyName: false
ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''
-KeepKeys¶
Keep only keys with a specified name.
Type: System.String[]
DefaultValue: ''
SupportsWildcards: false
Aliases:
- IgnoreKey
- KeepNames
ParameterSets:
- Name: (All)
Position: 4
IsRequired: false
ValueFromPipeline: false
ValueFromPipelineByPropertyName: false
ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''
-KeepNullOrEmptyValues¶
Remove keys with null or empty values.
Type: System.Management.Automation.SwitchParameter
DefaultValue: False
SupportsWildcards: false
Aliases:
- IgnoreNullOrEmptyValues
ParameterSets:
- Name: (All)
Position: Named
IsRequired: false
ValueFromPipeline: false
ValueFromPipelineByPropertyName: false
ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''
-KeepTypes¶
Keep only keys of a specified type.
Type: System.String[]
DefaultValue: ''
SupportsWildcards: false
Aliases:
- IgnoreTypes
ParameterSets:
- Name: (All)
Position: 3
IsRequired: false
ValueFromPipeline: false
ValueFromPipelineByPropertyName: false
ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''
-Keys¶
Remove keys with a specified name.
Type: System.String[]
DefaultValue: ''
SupportsWildcards: false
Aliases:
- Names
ParameterSets:
- Name: (All)
Position: 2
IsRequired: false
ValueFromPipeline: false
ValueFromPipelineByPropertyName: false
ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''
-NullOrEmptyValues¶
Remove keys with null or empty values.
Type: System.Management.Automation.SwitchParameter
DefaultValue: False
SupportsWildcards: false
Aliases: []
ParameterSets:
- Name: (All)
Position: Named
IsRequired: false
ValueFromPipeline: false
ValueFromPipelineByPropertyName: false
ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''
-Types¶
Remove keys of a specified type.
Type: System.String[]
DefaultValue: ''
SupportsWildcards: false
Aliases: []
ParameterSets:
- Name: (All)
Position: 1
IsRequired: false
ValueFromPipeline: false
ValueFromPipelineByPropertyName: false
ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''
CommonParameters¶
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.
INPUTS¶
System.Collections.Hashtable¶
{{ Fill in the Description }}
OUTPUTS¶
void¶
{{ Fill in the Description }}
System.Void¶
{{ Fill in the Description }}
NOTES¶
The function modifies the input hashtable but does not return output.