1. Since CustomFields is of type IDictionary, you have the ContainsKey method.
You can test if that CustomField is present.
Something like this
'yes'
}
else{
'nope'
}
2. I can't see an obvious issue, only that you seem to assign the same object twice.
Once inside the Get-vraDetails function and another time just after the call to Get-vraDetails.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference