PowerShell: Convert Object properties into HashTable

Everything is an object in PowerShell, and every object has it’s own properties, methods and some objects have events as well. Especially when it is working with the object properties, we can’t run through each property by its name & value in a loop, so to work with the individual properties we can convert the object properties into a HashTableand with the .GetEnumerator()and then you can manage the properties individually.

The script below to convert the object properties into HashTable…

Example output:

Convert-ObjectToHashTable

Thank you

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s