I'm trying to get all the field-value pairs into the same CSV.
## Works Individually ##
$cert = Get-ChildItem cert:\localmachine -Recurse
($cert.Extensions | Where-Object {$_.Oid.FriendlyName -eq "Key Usage"}).Format(0) | Select-Object -Property @{Name=Key Usage";Expression={$_}} |`
Export-csv -Path .\KeyUsage.csv
($cert.Extensions | Where-Object {$_.Oid.FriendlyName -eq "Basic Constraints"}).Format(0) | Select-Object - Property @{Name="basic constraints";Expression={$_}} |`
Export-csv -Path .\BasicConstraints.csv
## Does not work ##
$cert = Get-ChildItem cert:\localmachine -Recurse
($cert.Extensions | Where-Object {$_.Oid.FriendlyName -eq "Key Usage"}).Format(0) | Select-Object -Property @{Name="Key Usage";Expression={$_}},
($cert.Extensions | Where-Object {$_.Oid.FriendlyName -eq "Basic Constraints"}).Format(0) | Select-Object - Property @{Name="basic constraints";Expression={$_}} |`
Export-csv -Path .\File.csv
Perhaps I need to check to see if the field-value is null but how do i check that within the 'Expression'? It doesn't look like I can use if(!$_){}else{} to write in some zero'd values.