Coming soon - Get a detailed view of why an account is flagged as spam!
view details

This post has been de-listed

It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.

11
Powershell GUI Combobox Mapping To Objects
Post Flair (click to view more posts with a particular flair)
Post Body

How do I map PowerShell objects to windows form combo boxes?

$contracts = Get-MsolPartnerContract -All | select Name, DefaultDomainName, TenantID, ContractType | sort Name

$myform.combobox_contracts.DisplayMember = "{Name}"
$myform.combobox_contracts.ValueMember = "{TenantID}"
$myform.combobox_contracts.DataSource = $contracts

Trying to get something like the above to work in order to make mapping and selection of data easier.

For reference the Get-MSOLPartnerContract command above returns data like the following:

Name=Company Name;
DefaultDomainName=example.tld;
TenantID=<GUID>;
ContractType=[ResellerPartnerContract|SupportPartnerContract];

Currently this just displays the entire powershell object e.g.

@{Name=Microsoft;DefaultDomainName=Microsoft.com;TenantID=<GUID>;ContractType=ResellerPartnerContract}

I have tried changing combobox.displayname to:

  • Name
  • {Name}
  • $Contract | Get-Member -Name Name
  • $_.Name
  • ($Contract | Get-Member).Name

Will need to do something similar for combobox.valuemember.

I assume I am not too far off what is needed but just cannot quite get the correct combination. Thanks for any suggestions!

EDIT SOLVED: Told you all I was close! See the last line with conversion [collections.arraylist]$contracts

$contracts = Get-MsolPartnerContract -All | Select-Object Name, DefaultDomainName, TenantID, ContractType | Sort-Object Name

$myform.combobox_contracts.DisplayMember = "Name"
$myform.combobox_contracts.ValueMember = "TenantID"
$myform.combobox_contracts.DataSource = [collections.arraylist]$contracts

Author
Account Strength
100%
Account Age
10 years
Verified Email
Yes
Verified Flair
No
Total Karma
10,831
Link Karma
1,089
Comment Karma
9,498
Profile updated: 4 days ago
Posts updated: 1 year ago

Subreddit

Post Details

We try to extract some basic information from the post title. This is not always successful or accurate, please use your best judgement and compare these values to the post title and body for confirmation.
Posted
2 years ago