- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to clear all values from the Hash table in PowerShell?
Hash table in the PowerShell session is created temporarily. It is like a variable, when the session is closed, hash table is deleted automatically. If you want to delete all the values from the hash table at once but retaining the hash table variable, you need to use the Clear() method.
We have the hash table below created already.
$htable = [Ordered]@{EmpName="Charlie";City="New York";EmpID="001"}
PS C:\WINDOWS\system32> $htable Name Value ---- ----- EmpName Charlie City New York EmpID 001
To clear the above hashtable,
$htable.Clear()
If you check the hash table data, it won’t display anything now but it is still the OrderedDictionary and not converted into any variable data type.
- Related Articles
- How to add and remove values to the Hash Table in PowerShell?
- How to create a Hash Table in PowerShell?
- What is Hash Table in PowerShell?
- How to add/merge two hash tables in PowerShell?
- How to clear the content of the recycle bin in PowerShell?
- Remove elements from Javascript Hash Table
- Extracting Keys and Values from Hash in Perl
- How to clear all the input in HTML forms?
- How to clear old items in pivot table?
- Golang program to remove all items from hash collection
- How to get all the aliases in PowerShell?
- How to clear restricted values in cells in Excel?
- How to SELECT all values from a table only once if they're duplicated?
- How to delete all users from specific OU using PowerShell?
- How to clear table formatting style without losing table data in Excel?

Advertisements