Is it a way to remove the rows which doesn't contain any value-data? For this script, for example, the 'Department' value field is empty, I would like to trim it out.
[System.Object]$ADOutputSelectedValues = [ordered] @{
'FirstName' = $ADReturnObject.FirstName
'LastName' = $ADReturnObject.LastName
'Location' = $ADReturnObject.Location
'Department' = $ADReturnObject.Department
'Epost' = $ADReturnObject.Epost
'Id' = $ADReturnObject.Id
}
$Output = New-Object -TypeName psobject -Property $ADOutputSelectedValues
$Output
Edit: The current output is:
FirstName : Donald
LastName : Duck
Location : Dugburg
Department :
Epost : [email protected]
Id : 313
Would like it to look like this:
FirstName : Donald
LastName : Duck
Location : Dugburg
Epost : [email protected]
Id : 313
In advance, thanks.
Select-Object. ///// however, that will remove the item from ALL objects, not just the one. if you add code to remove the prop from only the one ... you will have a collection that cannot be exported to a CSV since that requires that the 1st object decide what all other objects props will be..Remove()method. ///// still, if you make a custom object of that item, you will need to be careful to make the same change to all the objects IF you intend to export them to a CSV file, since the 1st object will determine the columns for all the remaining objects.