1. Using PSCustomObject in array
$list = [System.Collections.ArrayList]@()
in for each loop assign value to info object and then add it to list
$info = [PSCustomObject]@{
"data1"="test 1"
"data2" = "test data 2"
}
[void]$list.Add($info)
then show it finally
$list | Show-ListView
2. Using Class, example given below:
class Topics {
[string]$TopicId
[string]$TopicPath
[string]$TopicName
}
create its array object
[Topics[]]$AllTopics = @()
assign values to it
$topicfolders|get-childitem |foreach-object{
$topic= [Topics]@{
TopicId = $_.Id
TopicPath= $_.fullpath
TopicName = $_.name
}
$AllTopics =[Array] $AllTopics + $topic
}
#then show $AllTopics
3. Directly assign value to psobject and show that
$customItem = [pscustomobject]@{
"ID"=$Item.ID
"Icon"=$Item.__Icon
"DisplayName"=$Item.DisplayName
"ItemPath"=$Item.ItemPath
"Version"=$Item.Version
"Language"=$Item.Language
"__Updated"=$Item.__Updated
"__Updated by"=$Item."__Updated by"
}
$customItem | Show-ListView
4.using Expression of show-listview, either give your value in it or create a function and use that to get values.