Как проверить, содержит хэш-таблица определенный ключ


This particular example checks if the hash table named $my_hashtable contains the key A0004.

This will return either True or False to indicate whether or not any element in the hash table contains the key.

 A0001 = ''; A0002 = ''; A0003 = ''; A0004 = ''; A0005 = ''; A0006 = ''; A0007 = '';
}

Как проверить, содержит хэш-таблица определенный ключ

Suppose we would like to check if the employee ID number A0004 exists as a key in this hash table.

PowerShell check if hash table contains key

This returns True since the employee ID number A0004 does indeed exist as a key in this hash table.

Suppose instead that we check if A0008 exists as as key in this hash table:

Как проверить, содержит хэш-таблица определенный ключ

This returns False since the employee ID number A0008 does not exist as a key in this hash table.

Also note that you can use the -and operator to check if multiple specific keys exist in a hash table.

.ContainsKey('') -and .ContainsKey('') 

PowerShell check if hash table contains multiple specific keys

This returns True since both A0002 and A0006 exist as keys in the hash table.

Note: You can find the complete documentation for the ContainsKey() method in PowerShell here.

PowerShell: A Simple Formula for “Not Contains”
PowerShell: How to Check if File Contains Specific String
PowerShell: How to Replace Special Characters in String

:/>  Winsat exe что это