- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
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 convert Dictionary to Hashtable in PowerShell?
Like any other data type conversion in PowerShell, we can convert Dictionary to hashtable in a similar way. We have a below Dictionary for the example called $CityData.
Key Value --- ----- India 91 Austria 43
Its datatype is Dictionary,
Example
PS C:\> $citydata.GetType() | ft -AutoSize
Output
IsPublic IsSerial Name BaseType -------- -------- ---- -------- True True Dictionary`2 System.Object
To convert it to the hashtable,
$hash = [Hashtable]$citydata
Or
$hash = [System.Collections.Hashtable]$CityData
Datatype:
PS C:\> $hash | ft -AutoSize
Output
Name Value ---- ----- Austria 43 India 91
- Related Articles
- How to convert command output to the Hashtable format in PowerShell?
- How to convert JSON object to Hashtable format using PowerShell?
- How to convert the hashtable to the JSON format using PowerShell?
- How to use Hashtable splatting in PowerShell?
- What is the difference between Dictionary and HashTable in PowerShell?
- How to Convert Hashtable to String?
- How to create a Dictionary in PowerShell?
- How to convert Javascript dictionary to Python dictionary?
- How to add multiple values in the Hashtable using PowerShell?
- How to Convert Hashtable into an Array?
- Hashtable vs. Dictionary in C#
- How to convert list to dictionary in Python?
- Convert string dictionary to dictionary in Python
- How to convert a string to dictionary in Python?
- How to convert Python Dictionary to a list?

Advertisements