Make helper functions more robust against undefined powershell objects