In powershell I have this code:
$AddTags = @()
$AddTags = $AddTags + "ABC"
$AddTags = $AddTags + "abc"
$Object = @{
"id" = 1;
"tags" = $AddTags
}
if($Object.tags -ne $AddTags)
{
"Why is this?"
}
For some reason, $Object.tags doesn't equal $AddTags. Why i hover over $Object in VS code debug mode, I can see that $Object.tags contains a hashtable with one Entry, being the key "tags" and the value $AddTags. Why is that?
I have searched for this Problem and haven't found it anywhere.
$Object.tags.GetType()--> System.Array. UseCompare-Objectto test if arrays have the same elements+=; which isn't recommended to begin with. So, it would be:$AddTags += 'ABC'; $AddTags += 'abc'