Skip to content

Instantly share code, notes, and snippets.

@phatmandrake
Created April 5, 2023 14:16
Show Gist options
  • Save phatmandrake/0411b5e598daab24950374d883bcc1ff to your computer and use it in GitHub Desktop.
Save phatmandrake/0411b5e598daab24950374d883bcc1ff to your computer and use it in GitHub Desktop.
Conditional Variable Assigments in a Hashtable cast to PSCustomObject
Get-Process -pv p | ForEach-Object {
[PSCustomObject]@{
Name = $p.name
ProcessHasDescription = $(if ($p.description) { $True }else { $False })
Description = $(if ($p.description) { $p.Description } else { $null })
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment