I have a variable which is declared as (for example)
$dict_object = @{Firstname="A";Lastname="B"}
I want to run another command , any command for example, Get-CIMInstance -class win32_BIOS
and I wanted to compare the output with the $dict_object variable using compare-object. The problem is that the $dict_object is a hashtable whereas the command output is not a hashtable. This is just example but is there any way to convert Powershell command output into a hashtable and compare it with a Hashtable variable/object. I tried using Convertfrom-stringData but it is not assigning key value pairs as expected.
For example, this is the command with convertfrom-stringdata
PS C:\Windows\System32> Get-CimInstance -class win32_bios | ConvertFrom-StringData
Name Value
---- -----
Win32_BIOS: 1.6.0 (Name "1.6.0", SoftwareElementID = "1.6.0", SoftwareElementState = 3, TargetOperatingSystem =…
versus normal output
PS C:\Windows\System32> Get-CimInstance -class win32_bios
SMBIOSBIOSVersion : 1.6.0
Manufacturer : Dell Inc.
Name : 1.6.0
SerialNumber : BDM8P93
Version : DELL - 20170001
I am expecting the above to has first column as key and second column as value but it seems ConvertFrom-StringData is not working that way.
I need this to compare existing variable with output from Get-WebconfigurationProperty (IIS Module) and if the value is not right, then else block will execute Add-webconfigurationProperty where I have tested that the Add-webconfigurationProperty takes HashTable as input