If I have a custom PowerShell Object with int, boolean, and PSCredential, I need to be able to write those out to a location. The easiest solution is to do a foreach loop, but I need to treat PSCredential differently of course. How can I exclude PSCredential from the foreach when writing out all other values?
Custom object is initialized similar to:
$myObj = [PSCustomObject]@{
Value1 = [string]
Value2 = [int]
Value3 = $null}
Further on in the processing of the script, Value3 is set to Get-Credential and the user is prompted for credentials.