Quantcast
Channel: PowerShell.org » All Posts
Viewing all articles
Browse latest Browse all 13067

Reply To: Formating output

$
0
0

Can you explain how you would like the list box to look? For instance, if you wanted something like this:

$roles | foreach{$_.PSObject.Properties | foreach{"{0} ({1})" -f $_.Value, $_.Name}}
 
server1.yourdomain.com (InfrastructureMaster)
server4.yourdomain.com (PDCEmulator)
server3.yourdomain.com (RIDMaster)

then you would just do:

$roles | foreach{$_.PSObject.Properties | foreach{$listbox1.Items.Add(("{0} ({1})" -f $_.Value, $_.Name))}}

if you only want the server names, then you can just use $_.Value versus

$listbox1.Items.Add($roles.InfrastructureMaster)
$listbox1.Items.Add($roles.PDCEmulator)
$listbox1.Items.Add($roles.RIDMaster)

I haven't done alot with Powershell GUI either, but you could also look at using a PSObject as a datasource. There should be a method like $listbox1.Source($roles). Just wanted to give you options.


Viewing all articles
Browse latest Browse all 13067

Trending Articles